A Vue.js project
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
For a detailed explanation on how things work, check out the guide and docs for vue-loader.
规定页面显示的效果
原理:要了解使用:
REST_FRAMEWORK = {
....
'DEFAULT_VERSIONING_CLASS':'rest_framework.versioning.URLPathVersioning',
'ALLOWED_VERSIONS':['v1','v2'], # 允许的版本
'VERSION_PARAM':'version', # 参数
'DEFAULT_VERSION':'v1', # 默认版本
....
}
urls.py:
urlpatterns = [
#url(r'^admin/', admin.site.urls),
url(r'^api/(?P<version>\w+)/', include('api.urls')),
]
api/urls.py :
urlpatterns = [
url(r'^course/$', course.CourseView.as_view()),
]
request.version 获取版本
- 路由 + 组件
- axios发送ajax请求
- that
-
跨域: (1)域名不同 (2)端口不同
-
cors: 本质设置响应头
#允许你的域名来获取我的数据 response['Access-Control-Allow-Origin'] = "*" # 允许你携带Content-Type请求头 response['Access-Control-Allow-Headers'] = "Content-Type" # 允许你发送DELETE,PUT response['Access-Control-Allow-Methods'] = "DELETE,PUT"
- source
- method
- 课程列表:this.$axios + this
- 课程详细:this.$axios + this
- 用户登录:
- this.$axios
- this
- 跨域简单和复杂请求
- vuex做全局变量
- vuex-cookies
- 微职位
- 拦截器
- 携带token
PS: api可以同一放在store中保存
-
课程列表
- 序列化:source='get_level_display'
-
课程详细:
- 序列化:source='get_level_display'
- 序列化:method
-
用户登录
- update_or_create
-
微职位
- 认证组件
-
关联组件:
- 版本
- 解析器
- 渲染器
- 序列化
- 认证组件
- 视图
- 路由