Vue组件生成依赖文件,contentype

每一个vue组件都有三部分

template:存放html代码

script: 存放js相关的东西

style: 存放css相关

vue中创建路由

创建一个组件

配置路由:

在router.js中加入

{

  path:'/freecource',

  name:'freecource',

  component:FreeCource},

路由跳转

<router-link to='/about'>About></router-link>

在组件中显示数据

在template:{{变量}}

在script:

  data:function(){

    return { cource_list:['1,2,2,3]}

vue中的axios:

安装: npm install axios 在package.json中就能看到依赖

在main.js中配置

import axios from 'axios'

Vue.prototype.$http=axios

在组件的js代码中写

this.$http://127.0.0.1:8804/courses/',

method:'get'}).then(function (response){ console.log(response.data)})

页面加载完成,执行数据加载

mounted:function(){ this.init()}

vue中使用element-ui

饿了么开源的样式

安装npm i element-ui -S

在main.js中配置

import ElementUI from 'element-ui';

import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI)

开放media路径

创建media文件夹在settings中配置

MEDIA_ROOT=os.path.join(BASE_DIR,'media')

在urls.py中

from django.views.static import serve

from luffy_city import settings

urlpatterns = [url(r'^media/(?P<path>.*)',serve,{'document_root':settings.MEDIA_ROOT})]

contentype

新建免费课程表的时候

不会在数据库中生成字段,只用于数据库操作

policy = GenericRelation(to='PricePolicy')

新建学位课程表的时候

不会在数据库中生成字段,只用于数据库操作

policy=GenericRelation(to='PricePolicy')

价格策略表

引入一个字段,不会再数据库中创建,只用来做数据库操作

content_obj = GenericForeignKey()

使用一(给课程添加价格策略):

给免费课django添加价格策略

course = models.Course.objects.get(pk=1)

ret = models.PricePolicy.objects.create(period=30,price=199.9,content_obj=couse)

给学位课程添加价格策略

degree_couse= models.DegreeCourse.objects.get(pk=1)

ret = models.PricePolicy.objects.create(period=30,price199.9,content_obj=degree_course)

使用二;查询价格策略对应的课程

price_policy = models.PricePolicy.objects.get(pk=1)

print(price_policy.content_obj)

使用三:通过课程获取价格策略

course = models.Course.objects.get(pk=1)

policy_list = course.policy.all()

消息队列

消息队列是在消息的传输过程中保存信息的容器

主要由于高并发环境下,来不及同步处理,请求往往会发生阻塞,使用消息队列可以异步处理请求,从而缓解系统的压力

从另一个Vue文件中导入变量

import HelloWorld from '@/components/HelloWorld.vue'

1.在cmd中或pycharm使用终端标签项切换到django的项目根目录

2.生成依赖文件
        pip freeze > requirements.txt

此会自动搜索工程中的所有依赖包名及相关版本到requirements.txt文件中

如果需要部署相关的工程,安装此文件中的依赖即可
    使用pip install -r requirements.txt 即可快速安装相关依赖


原文地址:https://www.cnblogs.com/suncunxu/p/10650084.html