全局配置:全局样式、配置文件
在js下创建setting.js ,配置全局的settings.js
import settings from '@/assets/js/settings'
Vue.prototype.$settings = settings;
export default {
base_url = 'http://127.0.0.1:8000'
}
配置全局的css样式
# import '@/assets/css/global.css' ###二者皆可
require('@/assets/css/global.css');
配置element-ui插件
①安装:cnpm install element-ui
②配置环境
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
配置jquery 和bootstrap环境
①安装:cnpm install jquery && cnpm install bootstrap@3
②配置环境:jq在vue.config.js中配置
import "bootstrap" // 加载bs的逻辑
import "bootstrap/dist/css/bootstrap.css"
vue.config.js
const webpack = require("webpack");
module.exports = {
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
"window.$": "jquery",
Popper: ["popper.js", "default"]
})
]
}
};
前后台交互跨越问题:CORS
配置axios来完成前后台ajax请求
1、安装:cnpm install axios
2、配置环境
import Axios from 'axios'
Vue.prototype.$axios = Axios;
配置cookie操作插件
1、安装:cnpm install vue-cookies
2、配置环境
import Cookies from 'vue-cookies'
Vue.prototype.$cookies = Cookies;