- main.js
这里我是想要从服务器获取网络连接路径 一些网络路径变动之后 只需要修改后台
import http from './utils/http'
Vue.use(vueSeamlessScroll)
Vue.use(ElementUI, { locale })
Vue.config.productionTip = false
async function main () {
new Vue({
el: '#app',
router,
render: h => h(App),
data: function () {
return {
local_url: '',
url_data: ''
}
},
mounted () {
http.get('http://ip:port/xxxx/xxxx').then((res) => {
this.$root.local_url = res.data.data.local_url
this.$root.url_data = res.data.data.url_data
axios.defaults.baseURL = this.$root.local_url
Vue.prototype.$http = axios
}).catch(() => {
})
}
})
}
main();
- 使用
this.$root.对象名