前言
在mpvue中,vuex對象不能注入到頁面和組件當中
如果使用了vuex輔助函數mapMutations與mapGetters,則在子組件中會報如下的錯誤:
解決方法:
將store對象通過$store
屬性添加到vue原型上,即:
Vue.prototype.$store = store
在main.js中,需要做一些更改:
import store from './store'
Vue.prototype.$store = store
在mpvue中,vuex對象不能注入到頁面和組件當中
如果使用了vuex輔助函數mapMutations與mapGetters,則在子組件中會報如下的錯誤:
將store對象通過$store
屬性添加到vue原型上,即:
Vue.prototype.$store = store
在main.js中,需要做一些更改:
import store from './store'
Vue.prototype.$store = store
onLoad(options) { this.page_query = options; }, onShow() { const _this = this; wx.page