自我总结57

vue的ajax插件:axios

"""
1)安装插件(一定要在项目目录下):
	>: cnpm install axios
	
2)在main.js中配置:
	import axios from 'axios'
	Vue.prototype.$axios = axios;
	

3)在任何一个组件的逻辑中发送ajax请求:
   this.$axios({
		url: '接口路径',
		method: 'get|post|delete|patch|put',
		params: {拼接参数},
		data: {数据包参数},
		headers: {请求头(认证信息)}
	}).then(response => {
		response.data
	}).catch(error => {
		error.response.data
	})
	
"""

CORS跨域问题(同源策略)

"""
同源:http协议相同、ip服务器地址相同、app应用端口相同
跨域:协议、ip地址、应用端口有一个不同,就是跨域

Django默认是同源策略,存在跨越问题。
Django的解决方案:

1)Django按照cors模块:
	>: pip install django-cors-headers
	
2)在settings注册模块,配置中间件:
    INSTALLED_APPS = [
        ...
        'corsheaders'
    ]
    MIDDLEWARE = [
        ...
        'corsheaders.middleware.CorsMiddleware'
    ]

3)在settings开启允许跨越:
	CORS_ORIGIN_ALLOW_ALL = True
"""

Vue配置ElementUI

"""
1)安装插件(一定要在项目目录下):
	>: cnpm install element-ui
	
2)在main.js中配置:
	import ElementUI from 'element-ui';
	import 'element-ui/lib/theme-chalk/index.css';
	Vue.use(ElementUI);
	

3)使用:
	灵魂:复制粘贴
	
"""

Vue配置jq+bs

jQuery

>: cnpm install jquery

vue/cli 3 配置jQuery:在vue.config.js中配置(没有,手动项目根目录下新建)

const webpack = require("webpack");

module.exports = {
    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $: "jquery",
                jQuery: "jquery",
                "window.jQuery": "jquery",
                Popper: ["popper.js", "default"]
            })
        ]
 		}
};

BootStrap

>: cnpm install bootstrap@3

vue/cli 3 配置BootStrap:在main.js中配置

import "bootstrap"
import "bootstrap/dist/css/bootstrap.css"
posted @ 2019-12-24 18:44  jzm1201  阅读(59)  评论(0编辑  收藏  举报