错误一:javascript
[Vue warn]: Property or method "$t" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.vue
解决方案:java
若是没有安装vuex和vuex-i18n须要先安装,而后在main.js中引入如下代码。在new Vue的时候,把store写上react
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app-box')vuex
import Vuex from 'vuex'; import vuexI18n from 'vuex-i18n'; Vue.use(Vuex); const store = new Vuex.Store({ modules: { i18n: vuexI18n.store } }); Vue.use(vuexI18n.plugin, store); const translationsEn = { "content": "This is some {type} content" }; Vue.i18n.add('en', translationsEn); Vue.i18n.set('en');
或者直接把$t删除,直接用相应的汉语或者英语。app
$t是一个翻译函数,若是你的项目不须要国际化,切换语言,那么你就能够把$t删除。函数
错误二:this
Uncaught TypeError: Cannot read property 'alert' of undefined at evalspa
解决方案:插件
import { AlertPlugin, DatetimePlugin, ConfirmPlugin, LoadingPlugin, ToastPlugin } from 'vux' Vue.use(AlertPlugin) Vue.use(DatetimePlugin) Vue.use(ConfirmPlugin) Vue.use(LoadingPlugin) Vue.use(ToastPlugin)
在main.js中加入以上代码,没有用到的插件能够不引入。以上几个是我总结出来的容易报错的几个插件。错误缘由是你的代码中使用了 this.$vux.alert等相似代码,而$vux是在插件中向vue中添加的,因此得引入相应的插件。