wepy 想在 mixins 中使用 mapState

555 阅读1分钟

wepy2的package.json


"@wepy/core": "^2.0.0-alpha.16",

"@wepy/x": "^2.0.2"

在mixins中使用 mapState


import { mapState, mapActions } from '@wepy/x'

export default {

computed: {

...mapState([ 'UserInfo' ])

},

methods: {

...mapActions(['storeSaveUserInfo'])

},

created() {}

}

wepy页面正常使用需要同时导入 common 和 stroe文件


<script>

import commonMixins from '@/mixins/common'

import store from '@/store'

wepy.page(

store,

mixins: [commonMixins]

)}

</script>

若只导入common不引入stroe则报错

image.png

点击 at WepyPage.mappedState (vendor.js?[sm]:4765) 跳转发现

this.$store.statethis.$store.getters 问题

image.png

若引入 mapGetters 同理报错

image.png