Vue.use(ElementUI)Vue.prototype.$axios = axiosVue.config.productionTip = falsenew Vue({el: '#app',router,store,//axios,i18n,template: '<App/>',components: { App }})在組件中使用$axios正常,this.$axios.get(可以正常執(zhí)行但如果用下面這種方式就會提示TypeError: Cannot read property 'get' of undefinedVue.use(ElementUI)//Vue.prototype.$axios = axiosVue.config.productionTip = falsenew Vue({el: '#app',router,store,axios,i18n,template: '<App/>',components: { App }})那么這兩種到底有什么區(qū)別呢?從我自己了解到的內(nèi)容,只知道在prototpye中使用的是實例中的屬性,在vue(){}中的是全局屬性,按照這種邏輯來說 我注冊到new vue(){}中不應該有問題啊,可是為什么不行呢,還有我理解Vue.use(ElementUI) 使用use方式的就是在使用標簽庫,我的理解對嗎?
將第三方插件放在 new Vue(){xxx}中和Vue.prototype.xxx=xxx的區(qū)別是
一只斗牛犬
2019-03-04 12:19:17