vue2中设置全局变量的最简单方法
在入口文件main.js中定义vue属性值:let a = {b:'bbb',c:'ccc'}Vue.prototype.$http = axios;Vue.prototype.$host = 'http://idol.fibonacci-tech.com/';Vue.prototype.$moment = moment;Vue.prototype.$a = ...
·
在入口文件main.js中定义vue属性值:
let a = {
b:'bbb',
c:'ccc'
}
Vue.prototype.$http = axios;
Vue.prototype.$host = 'http://idol.fibonacci-tech.com/';
Vue.prototype.$moment = moment;
Vue.prototype.$a = a;
在任何组件中引用:
this.$host...
this.$http.post...
更多推荐
已为社区贡献8条内容
所有评论(0)