在 main.js 主文件中的配置
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router/index'
import ElementUI from "element-ui";
import store from './store'
import "element-ui/lib/theme-chalk/index.css";
import http from './utils/http/http'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import './assets/all.scss'
import './assets/common.scss'
//重点
import axios from 'axios'
import message from './libs/message.js'
import echarts from "echarts";
import animated from 'animate.css' // npm install animate.css --save安装,在引入
import mixin from "./utils/mixin.js"
Vue.use(animated)
Vue.use(Antd)
Vue.use(ElementUI, {
size: "small"
});
Vue.config.productionTip = false
Vue.prototype.$message = message
Vue.prototype.$http = http;
Vue.prototype.$echarts = echarts
function setTree(arr, bm, pid, id, mc) {
const newArr = []
for (const item of arr) {
item.selected = item.selected||false
if(mc && item[mc].indexOf(item[id])== -1){
item[mc] = `${item[mc]}(${item[id]})`
}
if (item[pid] === bm) {
item.children = setTree(arr, item[id], pid, id, mc)
newArr.push(item)
}
}
return newArr
}
Vue.prototype.$setTree = setTree
Vue.prototype.$formDate = formDate
Vue.mixin(mixin)
// 引入固定的配置文件 ,然后将字段写入vue对象中
axios.get('/static/config.json').then(res => {
Vue.prototype.$DWMC = res.DWMC
Vue.prototype.$DWJC = res.DWJC
Vue.prototype.$TJCS = res.TJCS
axios.defaults.baseUrl = res.BASE_URL
Vue.prototype.BASE_URL = res.BASE_URL
new Vue({
el: '#app',
router,
store,
components: {
App
},
template: '<App/>'
})
})
配置文件 在src 文件外 static\config.json
{
"BASE_URL":"http://192.168.XX.XX:端口号",
"DWMC":"项目名成",
"DWJC":"XX",
"TJCS":"21122"
}