//main.ts里面import*asapifrom'@/api'//接口方法Vue.prototype.$api=apiApp.vue里面import{Vue,Component}from'vue-property-decorator'@ComponentexportdefaultclassAppextendsVue{publiccreated(){this.$api.getUserInfo().then(res=>{console.log(res,'res')}).catch(err=>{console.log(err,'err')})}publicmounted(){}}我在App.vue里面調用this.$api.xxx能夠正常調用到api里面的方法,但是編譯的時候會報錯警告Property'$api'doesnotexistontype'App'.請問這個怎么回事?。?
vue-cli3 + ts 通過Vue.prototype綁定的屬性方法,能夠調用到,但是編譯報錯謝謝哈~
飲歌長嘯
2019-10-19 09:12:51