标签:策略 window prototype 应用 exp bootstra ide The pac
目录
node_modules不需要动
public不动
src中在assets中创建css js 和img文件夹
router文件夹中的index.js只保留一个home的路由配置
App.vue只留五行代码即可
Home.vue删掉后创新的
>: cnpm install axios
    import axios from 'axios'
    Vue.prototype.$axios = axios;
   this.$axios({
        url: 'http://127.0.0.1:8000/cars/',
        method: 'get',
    }).then(response => {
        console.log(response);
        // this.cars = response.data;
    }).catch(error => {  // 网络状态码为4xx、5xx
        console.log(error);
    });
同源: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
1)安装插件(一定要在项目目录下):
    >: cnpm install element-ui
2)在main.js中配置:
    import ElementUI from 'element-ui';
    import 'element-ui/lib/theme-chalk/index.css';
    Vue.use(ElementUI);
>: cnpm install jquery
const webpack = require("webpack");
module.exports = {
    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $: "jquery",
                jQuery: "jquery",
                "window.jQuery": "jquery",
                Popper: ["popper.js", "default"]
            })
        ]
        }
};
>: cnpm install bootstrap@3
import "bootstrap"
import "bootstrap/dist/css/bootstrap.css"标签:策略 window prototype 应用 exp bootstra ide The pac
原文地址:https://www.cnblogs.com/LZF-190903/p/12115980.html