Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixins 下使用 mapState #2761

Open
476421978 opened this issue Aug 13, 2021 · 0 comments
Open

mixins 下使用 mapState #2761

476421978 opened this issue Aug 13, 2021 · 0 comments

Comments

@476421978
Copy link

476421978 commented Aug 13, 2021

Description

想在wepy的mixins下使用mapState

Environment

  • Platform: vscode
  • Wechat version: 2.19.1
  • wepy version: "@wepy/core": "^2.0.0-alpha.16"
  • wepy/x version: "@wepy/x": "^2.0.2

Reproduce

只需在mixins中引入mapState搭配store下任意state即可
例如:

mixins/common.js

import { mapState } from '@wepy/x'
export default {
  computed: {
    ...mapState([ 'UserInfo' ])
  }
}

store/index.js

import Vuex from '@wepy/x'
export default new Vuex.Store({
  state: {
    UserInfo: {}
  }
})

对应的wpy页面引用

<script>
import commonMixins from '@/mixins/common'
wepy.page({
    mixins: [commonMixins],
})
</script>

Observed Results

image

页面this.$store为null

Expected Results

[期望表现]
能正常运行不报错

Relevant Code / Logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant