一、简单回顾vue

前不久我们已经了解了vue前端框架,所以现在强调几点:

  1. 修改源:
  2. npm config set registry https://registry.npm.taobao.org
  3.  
  4. 创建脚手架:
  5. vue init webpack Vue项目名称
  6. #记得把route的这个设置为yes,其他的设置为no 比如: Install vue-router? Yes
  7.  
  8. 插件:
  9. axios,发送Ajax请求
  10. vuex,保存所有组件共用的变量
  11. vue-cookies,操作cookie

二、流程详细

1、创建脚手架

  1. #可以用淘宝源来下载,这样下载的快
  2. npm config set registry https://registry.npm.taobao.org
  3. vue init webpack
  1. #吧route的那一个设置为yes,其他的设置为no

2、运行

  1. cd Vue项目名称
  2. npm run dev

3、显示组件

  1. # 用于点击查看组件
  2. <router-link to="/index">首页</router-link>
  3.  
  4. # 组件显示的位置
  5. <router-view/>

4、写路由

  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import Index from '@/components/Index'
  4. import Login from '@/components/Login'
  5. import Course from '@/components/Course'
  6. import Micro from '@/components/Micro'
  7. import News from '@/components/News'
  8. import CourseDetail from '@/components/CourseDetail'
  9. import NotFound from '@/components/NotFound'
  10.  
  11. Vue.use(Router)
  12.  
  13. export default new Router({
  14. routes: [
  15. {
  16. path: '/',
  17. name: 'index',
  18. component: Index
  19. },
  20. {
  21. path: '/index',
  22. name: 'index',
  23. component: Index
  24. },
  25. {
  26. path: '/course',
  27. name: 'course',
  28. component: Course
  29. },
  30. {
  31. path: '/course-detail/:id/',
  32. name: 'courseDetail',
  33. component: CourseDetail
  34. },
  35. {
  36. path: '/micro',
  37. name: 'micro',
  38. component: Micro
  39. },
  40. {
  41. path: '/news',
  42. name: 'news',
  43. component: News
  44. },
  45. {
  46. path: '/login',
  47. name: 'login',
  48. component: Login
  49. },
  50. {
  51. path: '*',
  52. component: NotFound
  53. }
  54. ],
  55. mode: 'history'
  56. })
  1. # 定义路由
  2. {
  3. path: '/course-detail/:id/',
  4. name: 'courseDetail',
  5. component: CourseDetail
  6. },
  7. {
  8. path: '/login',
  9. name: 'login',
  10. component: Login
  11. },
  12. {
  13. path: '*',
  14. component: NotFound
  15. }
  16.  
  17. # router-link参数
  18. <router-link :to="{'path':'/course-detail/'+item.id }">{{item.name}}</router-link>
  19. <router-link to="/index">首页</router-link>
  20.  
  21. # 获取传过来的参数
  22. this.$route.params.id
  23. # 重定向
  24. this.$router.push('/index')

注意:

如果不想在url显示#,可以在路由里面加上这样一个参数

  1. mode: 'history'

5、写组件

  1. <template>
  2.  
  3. <div>
  4. <h1>登录页面</h1>
  5. <div>
  6. <input type="text" v-model="username" placeholder="用户名">
  7. <input type="text" v-model="password" placeholder="密码">
  8. <a @click="doLogin">提交</a>
  9. </div>
  10. </div>
  11. </template>
  12.  
  13. <script>
  14.  
  15. export default {
  16. # 定义局部字段
  17. data () {
  18. return {
  19. username: '',
  20. password: ''
  21. }
  22. },
  23. # 加载时执行
  24. mounted:function(){
  25. },
  26. # 定义局部方法
  27. methods:{
  28. doLogin() {
  29. var that = this
  30. this.$axios.request({
  31. url: 'http://127.0.0.1:8000/login/',
  32. method: 'POST',
  33. data: {
  34. username: this.username,
  35. password: this.password
  36. },
  37. responseType: 'json'
  38. }).then(function (response) {
  39. console.log(response.data)
  40. // 找到全局变量,把用户名和token赋值到其中。
  41. that.$store.commit('saveToken',response.data)
  42. // 重定向到index
  43. that.$router.push('/index')
  44. })
  45. }
  46. }
  47. }
  48. </script>
  49.  
  50. <!-- Add "scoped" attribute to limit CSS to this component only -->
  51. <style scoped>
  52.  
  53. </style>

6、发送ajax请求:axios

  1. #发送ajax请求需要安装axios组件
  2. npm install axios
  1. npm install axios
  2.  
  3. main.js
  4. import Vue from 'vue'
  5. import App from './App'
  6. import router from './router'
  7.  
  8. import axios from 'axios'
  9.  
  10. Vue.prototype.$axios = axios
  11.  
  12. Vue.config.productionTip = false
  13. ...
  14.  
  15. 组件使用:
  16. this.$axios.request({
  17. url: 'http://127.0.0.1:8000/login/',
  18. method: 'POST',
  19. data: {
  20. username: this.username,
  21. password: this.password
  22. },
  23. responseType: 'json'
  24. }).then(function (response) {
  25. console.log(response.data)
  26.  
  27. that.$router.push('/index')
  28. })
  29.  
  30. PS:重定向 that.$router.push('/index')

7、vuex:保存所有组件共用的变量

  1. 安装
  2. npm install vuex

如果想用vuex需要做这么几件事:

  • a、先创建一个文件夹,store----store.js
  • b、要先使用就先导入
  • c、实例化一个对象,并且让别人可以用
  • d、这样每一个组件都可以用username和token了
  1. npm install vuex
  2.  
  3. main.js
  4. import Vue from 'vue'
  5. import App from './App'
  6. import router from './router'
  7. import axios from 'axios'
  8.  
  9. import store from './store/store' # vuex
  10.  
  11. Vue.prototype.$axios = axios
  12.  
  13. Vue.config.productionTip = false
  14.  
  15. /* eslint-disable no-new */
  16. new Vue({
  17. el: '#app',
  18. store, # vuex
  19. router,
  20. components: { App },
  21. template: '<App/>'
  22. })
  23.  
  24. src/store/store.js
  25. import Vue from 'vue'
  26. import Vuex from 'vuex'
  27. import Cookie from 'vue-cookies'
  28.  
  29. Vue.use(Vuex)
  30.  
  31. export default new Vuex.Store({
  32. // 组件中通过 this.$store.state.username 调用
  33. state: {
  34. username: Cookie.get('username'),
  35. token: Cookie.get('token')
  36. },
  37. mutations: {
  38. // 组件中通过 this.$store.commit(参数) 调用
  39. saveToken: function (state, data) {
  40. state.username = data.username
  41. state.token = data.token
  42. Cookie.set('username', data.username, '20min')
  43. Cookie.set('token', data.token, '20min')
  44.  
  45. },
  46. clearToken: function (state) {
  47. state.username = null
  48. state.token = null
  49. Cookie.remove('username')
  50. Cookie.remove('token')
  51. }
  52. }
  53. })

8、vue-cookies:操作cookie

  1. 安装
  2. npm install vue-cookies
  1. npm install vue-cookies
  2.  
  3. Cookie.get('username')
  4.  
  5. Cookie.set('username', data.username, '20min')
  6. Cookie.remove('username')
  7.  
  8. src/store/store.js
  9. import Vue from 'vue'
  10. import Vuex from 'vuex'
  11. import Cookie from 'vue-cookies' # vue-cookies
  12.  
  13. Vue.use(Vuex)
  14.  
  15. export default new Vuex.Store({
  16. // 组件中通过 this.$store.state.username 调用
  17. state: {
  18. username: Cookie.get('username'), # vue-cookies
  19. token: Cookie.get('token') # vue-cookies
  20. },
  21. mutations: {
  22. // 组件中通过 this.$store.commit(参数) 调用
  23. saveToken: function (state, data) {
  24. state.username = data.username
  25. state.token = data.token
  26. Cookie.set('username', data.username, '20min') # vue-cookies
  27. Cookie.set('token', data.token, '20min')
  28.  
  29. },
  30. clearToken: function (state) {
  31. state.username = null
  32. state.token = null
  33. Cookie.remove('username') # vue-cookies
  34. Cookie.remove('token')
  35. }
  36. }
  37. })

三、代码实现

前端代码:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  6. <link rel="stylesheet" href="./static/bootstrap-3.3.7-dist/css/bootstrap.css">
  7. <script src="./static/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
  8.  
  9. <title>s6vue</title>
  10. </head>
  11. <body>
  12. <div id="app"></div>
  13. <!-- built files will be auto injected -->
  14. </body>
  15. </html>

index.html

  1. // The Vue build version to load with the `import` command
  2. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  3. import Vue from 'vue'
  4. import App from './App'
  5. import router from './router'
  6. import store from './store/store' //
  7. import axios from 'axios' // 要是用axios,就得先导入
  8. Vue.prototype.$axios = axios //注册,以后就可以用$axios来定义了
  9.  
  10. Vue.config.productionTip = false
  11.  
  12. /* eslint-disable no-new */
  13. new Vue({
  14. el: '#app',
  15. store,
  16. router,
  17. components: { App },
  18. template: '<App/>'
  19. })

main.js

  1. <template>
  2. <div id="app">
  3. <!--首页里面永远是固定的东西-->
  4. <ul class="nav nav-tabs">
  5. <li><router-link to="/index">首页</router-link> <!--用于点击查看组件--></li>
  6. <li><router-link to="/micro">学位课</router-link> <!--用于点击查看组件--></li>
  7. <li><router-link to="/course">课程</router-link></li> <!--用于点击查看组件-->
  8. <li><router-link to="/news">深科技</router-link></li> <!--用于点击查看组件-->
  9. <!--如果已经登录了,就不用在登录了,在页面还是显示当前用户和注销,如果没有登录就显示登录-->
  10. <li v-if="this.$store.state.username">
  11. <span><a>欢迎{{ this.$store.state.username }}登录</a></span>
  12. <span><a @click="logout()">注销</a></span>
  13. </li>
  14. <li v-else=""> <router-link to="/login">登录</router-link></li>
  15. </ul>
  16. <router-view/> <!--组件显示的位置-->
  17. </div>
  18. </template>
  19.  
  20. <script>
  21. export default {
  22. name: 'App',
  23. methods:{
  24. logout(){
  25. this.$store.state.username=''
  26. this.$store.state.token=''
  27. }
  28. }
  29. }
  30. </script>
  31.  
  32. <style>
  33.  
  34. </style>

app.vue

  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import HelloWorld from '@/components/HelloWorld'
  4. import Index from '@/components/Index'
  5. import Login from '@/components/Login'
  6. import Micro from '@/components/Micro'
  7. import News from '@/components/News'
  8. import Course from '@/components/Course'
  9. import CourseDetail from '@/components/CourseDetail'
  10. import NotFound from '@/components/NotFound'
  11.  
  12. Vue.use(Router)
  13.  
  14. export default new Router({
  15. routes: [
  16. {
  17. path: '/',
  18. name: 'HelloWorld',
  19. component: HelloWorld
  20. },
  21. {
  22. path: '/index',
  23. name: 'index',
  24. component: Index
  25. },
  26. {
  27. path: '/login',
  28. name: 'Login',
  29. component: Login
  30. },
  31. {
  32. path: '/course',
  33. name: 'Course',
  34. component: Course
  35. },
  36. {
  37. path: '/course-detail/:id/',
  38. name: 'CourseDetail',
  39. component: CourseDetail
  40. },
  41. {
  42. path: '/micro/',
  43. name: 'Micro',
  44. component: Micro
  45. },
  46. {
  47. path: '/course-detail/:id/',
  48. name: 'CourseDetail',
  49. component: CourseDetail
  50. },
  51. {
  52. path: '/news/',
  53. name: 'News',
  54. component: News
  55. },
  56. {
  57. path: '*',
  58. component: NotFound
  59. }
  60. ],
  61. mode:'history'
  62. })

router ---index.js

组件components

  1. <template>
  2. <div class="hello">
  3. <h1>{{ msg }}</h1>
  4. </div>
  5. </template>
  6.  
  7. <script>
  8. export default {
  9. name: 'index',
  10. data () {
  11. return {
  12. msg:"这里是首页"
  13. }
  14. }
  15. }
  16. </script>
  17.  
  18. <!-- Add "scoped" attribute to limit CSS to this component only -->
  19. <style>
  20.  
  21. </style>

Index.vue

  1. <template>
  2. <div class="">
  3. <h2>登录页面</h2>
  4. <p>用户名:<input type="text" placeholder="username" v-model="username"></p>
  5. <p>密码:<input type="text" placeholder="password" v-model="password"></p>
  6. <button><a @click="DoLogin()">提交</a></button>
  7. </div>
  8. </template>
  9.  
  10. <script>
  11. export default {
  12. name: 'index',
  13. data () {
  14. return {
  15. username: "",
  16. password: ""
  17. }
  18. },
  19. methods:{
  20. DoLogin (){
  21. var that = this
  22. // console.log(this.$axios);
  23. this.$axios.request({ //发送axios请求
  24. url:'http://127.0.0.1:8082/login/', //请求路径
  25. method:"POST",//请求方式
  26. data:{ //要发送 的数据
  27. username:this.username,
  28. password:this.password
  29. },
  30. responseType:'json' //期望返回的类型是json的格式
  31. }).then(function (response) { //吧返回的结果交给回调函数处理
  32. //登录成功之后,找到全局变量,吧用户名和token赋值到其中
  33. that.$store.commit('saveToken',response.data);
  34. //重定向(登录成功之后让跳转到index页面)
  35. that.$router.push('/index')
  36. //为什么不直接用this呢?这里的this代表的是$axios,用that他代指的是整个Vue对象
  37. })
  38. }
  39. }
  40.  
  41. }
  42. </script>
  43.  
  44. <!-- Add "scoped" attribute to limit CSS to this component only -->
  45. <style>
  46.  
  47. </style>

Login.vue

  1. <template>
  2. <div class="">
  3. <ul>
  4. <li v-for="item in courseList">
  5. <router-link :to="{'path':'/course-detail/'+item.id}">{{item.name}}</router-link>
  6. </li>
  7. </ul>
  8. </div>
  9. </template>
  10.  
  11. <script>
  12. export default {
  13. name: 'index',
  14. data () {
  15. return {
  16. msg:'课程页面',
  17. courseList:[]
  18. }
  19. },
  20. mounted:function () {
  21. //当组件一加载的时候就应该去数据库去获取数据
  22. this.initCourses()
  23. },
  24. methods:{
  25. initCourses:function () {
  26. var that = this
  27. this.$axios.request({
  28. url:'http://127.0.0.1:8082/course/',
  29. method:"GET"
  30. }).then(function (response) {
  31. console.log(response);
  32. that.courseList = response.data.courseList //吧从数据库取的数据赋值到courseList列表里面
  33. })
  34. }
  35. }
  36.  
  37. }
  38.  
  39. </script>
  40.  
  41. <!-- Add "scoped" attribute to limit CSS to this component only -->
  42. <style>
  43.  
  44. </style>

course.vue

  1. <template>
  2. <div class="hello">
  3. <div>课程详细</div>
  4. <h3>{{ title }}</h3>
  5. <h3>{{ summary }}</h3>
  6. </div>
  7. </template>
  8.  
  9. <script>
  10. export default {
  11. name: 'HelloWorld',
  12. data () {
  13. return {
  14. title:'',
  15. summary:''
  16. }
  17. },
  18. mounted:function () {
  19. //当组件一加载就执行的函数
  20. this.initCoursesDetail()
  21. },
  22. methods:{
  23. initCoursesDetail(){
  24. var nid = this.$route.params.id //获取id
  25. var that = this
  26. var url = 'http://127.0.0.1:8082/course/' + nid + '.json'
  27. this.$axios.request({
  28. url:url,
  29. methods:'GET',
  30. responseType:'json'
  31. }).then(function (response) {
  32. console.log(response)
  33. that.title = response.data.title;
  34. that.summary = response.data.summary
  35. })
  36. }
  37. }
  38. }
  39. </script>
  40.  
  41. <!-- Add "scoped" attribute to limit CSS to this component only -->
  42. <style scoped>
  43.  
  44. </style>

CoursesDetail

  1. <template>
  2. <div class="hello">
  3. <h2>欢迎报名学位课</h2>
  4. </div>
  5. </template>
  6.  
  7. <script>
  8. export default {
  9. name: 'HelloWorld',
  10. data () {
  11. return {
  12. msg: 'Welcome to Your Vue.js App'
  13. }
  14. }
  15. }
  16. </script>
  17.  
  18. <!-- Add "scoped" attribute to limit CSS to this component only -->
  19. <style scoped>
  20. h1, h2 {
  21. font-weight: normal;
  22. }
  23. ul {
  24. list-style-type: none;
  25. padding: 0;
  26. }
  27. li {
  28. display: inline-block;
  29. margin: 0 10px;
  30. }
  31. a {
  32. color: #42b983;
  33. }
  34. </style>

Micro.vue

  1. <template>
  2. <div class="hello">
  3. <h2>深科技</h2>
  4. </div>
  5. </template>
  6.  
  7. <script>
  8. export default {
  9. name: 'HelloWorld',
  10. data () {
  11. return {
  12. msg: 'Welcome to Your Vue.js App'
  13. }
  14. }
  15. }
  16. </script>
  17.  
  18. <!-- Add "scoped" attribute to limit CSS to this component only -->
  19. <style scoped>
  20. h1, h2 {
  21. font-weight: normal;
  22. }
  23. ul {
  24. list-style-type: none;
  25. padding: 0;
  26. }
  27. li {
  28. display: inline-block;
  29. margin: 0 10px;
  30. }
  31. a {
  32. color: #42b983;
  33. }
  34. </style>

News.vue

  1. <template>
  2. <div class="hello">
  3. <h1>找不到页面</h1>
  4. </div>
  5. </template>
  6.  
  7. <script>
  8. export default {
  9. name: 'HelloWorld',
  10. data () {
  11. return {
  12. msg: 'Welcome to Your Vue.js App'
  13. }
  14. }
  15. }
  16. </script>
  17.  
  18. <!-- Add "scoped" attribute to limit CSS to this component only -->
  19. <style scoped>
  20. h1, h2 {
  21. font-weight: normal;
  22. }
  23. ul {
  24. list-style-type: none;
  25. padding: 0;
  26. }
  27. li {
  28. display: inline-block;
  29. margin: 0 10px;
  30. }
  31. a {
  32. color: #42b983;
  33. }
  34. </style>

NotFound

保存全局使用的变量store

  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import Cookie from 'vue-cookies'
  4.  
  5. Vue.use(Vuex)
  6.  
  7. export default new Vuex.Store({
  8. //组件中通过this.$store.state.username 调用
  9. state:{
  10. username:Cookie.get('username'),
  11. token:Cookie.get('token')
  12. },
  13. mutations:{
  14. //组件中通过this.$store.commit(参数)调用
  15. saveToken:function (state,data) { //存放用户名和token的函数
  16. state.username = data.username //data代指从后端返回过来的数据
  17. state.token = data.token
  18. Cookie.set('username',data.username,'20min') //吧用户名和token存放到cookie中
  19. Cookie.set('token',data.token,'20min')
  20. },
  21. //清空token和cookie
  22. clearToken:function (state) {
  23. state.username=null
  24. state.token= null
  25. Cookie.remove('username')
  26. Cookie.remove('token')
  27. }
  28. }
  29. })

store.js

后端代码:

  1. """day145vue和restful配合 URL Configuration
  2.  
  3. The `urlpatterns` list routes URLs to views. For more information please see:
  4. https://docs.djangoproject.com/en/1.11/topics/http/urls/
  5. Examples:
  6. Function views
  7. 1. Add an import: from my_app import views
  8. 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
  9. Class-based views
  10. 1. Add an import: from other_app.views import Home
  11. 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
  12. Including another URLconf
  13. 1. Import the include() function: from django.conf.urls import url, include
  14. 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
  15. """
  16. from django.conf.urls import url
  17. from django.contrib import admin
  18. from api import views
  19. urlpatterns = [
  20. url(r'^admin/', admin.site.urls),
  21. url(r'^login/', views.LoginView.as_view()),
  22. url(r'^course/$', views.CourseView.as_view()),
  23. url(r'^course/(?P<pk>\d+)\.(?P<format>[a-z-9]+)$', views.CourseView.as_view()),
  24. ]

urls.py

  1. from django.shortcuts import render,HttpResponse
  2. from rest_framework.views import APIView
  3. from rest_framework.response import Response
  4. from django.http import JsonResponse
  5.  
  6. class LoginView(APIView):
  7.  
  8. def get(self,request,*args,**kwargs):
  9. ret = {
  10. 'code':111,
  11. 'data':'在知识的海洋里一路向前'
  12. }
  13.  
  14. response = JsonResponse(ret)
  15. response['Access-Control-Allow-Origin']='*'
  16. return response
  17.  
  18. def post(self,request,*args,**kwargs):
  19. print(request.body) #在body里面有值
  20. print(request.POST) #在post里面是没有值的
  21. ret = {
  22. 'code':1000,
  23. 'username':'haiyn',
  24. 'token':'sdswr3fdfsdfdxqw2fgh',
  25. }
  26. response = JsonResponse(ret)
  27. response['Access-Control-Allow-Origin'] = "*"
  28. return response
  29.  
  30. def options(self, request, *args, **kwargs):
  31. response = HttpResponse()
  32. response['Access-Control-Allow-Origin'] = '*'
  33. response['Access-Control-Allow-Headers'] = '*'
  34. # response['Access-Control-Allo w-Methods'] = 'PUT'
  35. return response
  36.  
  37. class CourseView(APIView):
  38. def get(self,request,*args,**kwargs):
  39. print(args,kwargs)
  40. pk = kwargs.get('pk')
  41. if pk:
  42. print(kwargs.get('pk'))
  43. ret = {
  44. 'title': "标题标题标题",
  45. 'summary': '老师,太饿了。怎么还不下课'
  46. }
  47. else:
  48. ret = {
  49. 'code':1000,
  50. 'courseList':[
  51. {'name':'人生苦短,来学Python','id':1},
  52. {'name':'32天学会java,欢迎报名','id':2},
  53. {'name':'人工智能即将统领世界...','id':3},
  54. ]
  55. }
  56. response= JsonResponse(ret)
  57. response['Access-Control-Allow-Origin'] = '*'
  58. return response

views.py

Vue+restfulframework示例的更多相关文章

  1. Vue 项目 Vue + restfulframework

    Vue 项目 Vue + restfulframework 实现登录认证 - django views class MyResponse(): def __init__(self): self.sta ...

  2. Vue 1-- ES6 快速入门、vue的基本语法、vue应用示例,vue基础语法

    一.ES6快速入门 let和const let ES6新增了let命令,用于声明变量.其用法类似var,但是声明的变量只在let命令所在的代码块内有效. { let x = 10; var y = 2 ...

  3. Vue(1)- es6的语法、vue的基本语法、vue应用示例,vue基础语法

    一.es6的语法 1.let与var的区别 ES6 新增了let命令,用来声明变量.它的用法类似于var(ES5),但是所声明的变量,只在let命令所在的代码块内有效.如下代码: { let a = ...

  4. python 之CORS,VUE+rest_framework示例

    一.跨域     浏览器的同源策略                 ----对ajax请求进行阻拦                 ----对href属性读不阻拦        xhr=new XML ...

  5. Vue.js示例:GitHub提交(watch数据,created钩子,filters过滤); 网格组件(功能:1.检索,2排序);

    GitHub提交 codePen:   https://codepen.io/chentianwei411/pen/wEVPZo 注意:频繁看案例,可能会被限制. 重点: 表单输入绑定, 单选按钮的使 ...

  6. Django rest framework + Vue简单示例

    构建vue项目参考这篇文章https://segmentfault.com/a/1190000008049815 一.创建Vue项目 修改源:npm config set registry https ...

  7. VUE购物车示例

    代码下载地址:https://github.com/MengFangui/VueShoppingCart 1.index.html <!DOCTYPE html> <html lan ...

  8. webAPP如何实现移动端拍照上传(Vue组件示例)?

    摘要:使用HTML5编写移动Web应用,主要是为了尝试一下“一套代码多处运行”,一个webapp几乎可以不加修改的运行在PC/Android/iOS等上面运行.但是写到现在觉得虽然这种方式弊大于利,不 ...

  9. Vue.js示例:树型视图; 模式组件;

    树型图 本示例是一个简单的树形视图实现,它展现了组件的递归使用. mycode pen:https://codepen.io/chentianwei411/pen/KGKQxE 重点:递归是如何形成的 ...

随机推荐

  1. UOJ #30【CF Round #278】Tourists

    求从$ x$走到$ y$的路径上可能经过的最小点权,带修改  UOJ #30 $ Solution:$ 如果两个点经过了某个连通分量,一定可以走到这个连通分量的最小值 直接构建圆方树,圆点存原点的点权 ...

  2. Redis 深度历险

    学习资料 https://juejin.im/book/5afc2e5f6fb9a07a9b362527 包括下面几方面的内容 基础 应用 原理 集群 拓展 源码 to be done

  3. 使用jQuery重置(reset)表单的方法

    由于JQuery中,提交表单是像下面这样的: 代码如下: $('#yigeform').submit() 所以,想当然的认为,重置表单,当然就是像下面这样子喽: 代码如下: $('#yigeform' ...

  4. 【编程拾遗】C++的static成员函数与单例模式

    static小结 static的引入 static 是C++中非经常常使用的修饰符,它被用来控制变量的存储方式和可见性. 函数内部定义的变量,在程序运行到它的定义处时,编译器为它在栈上分配空间,函数在 ...

  5. Navicat for MySQL 12中文版 破解流程

    1.下载  Keygen_Patch 软件 下载地址 pass: saxz 2.启动 Keygen_Patch 软件 3.提示破解成功了,先别着急 4.运行 Navica  软件,输入注册码 5.断网 ...

  6. 目标检测----ImageAI使用

    1.开源项目  github地址  https://github.com/OlafenwaMoses/ImageAI 2.目标检测(Object Detection)入门概要 3.Pycharm中无法 ...

  7. [Kubernetes]如何使用yaml文件使得可以向外暴露服务

    最近因为项目需要上线,所以这段时间都扑到了Kubernetes上面. 昨天老大交代了一个任务,大概就是这样的: 看起来挺简单的,因为相关文件都给我了,我以为直接把文件拖上去,然后在访问ip:port方 ...

  8. [Harbor]Docker登录Harbor仓库(HTTP方式)

    Docker登录到Harbor仓库时,不管是使用http协议还是使用https协议,都需要修改一些配置. 这篇文章来介绍一下,在使用http协议时,需要进行什么哪些配置. 首先,确定自己的Harbor ...

  9. Path Sum I && II & III

    Path Sum I Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that ad ...

  10. python 字典不区分大小写工具类

    # -*- coding: utf-8 -*- # @Time : 2018/12/20 4:28 PM # @Author : cxa # @File : DictHelper.py # @Soft ...