在入口文件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...
本文介绍如何在Vue项目中设置全局可用的属性,如$http、$host等,并展示如何在组件中使用这些配置。
在入口文件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...
2420
2812

被折叠的 条评论
为什么被折叠?