...mapState({
a: state => state.some.nested.module.a,
b: state => state.some.nested.module.b
})
简写带空间名称的字符串
...mapState(‘some/nested/module‘, {
a: state => state.a,
b: state => state.b
})
...mapActions([ ‘some/nested/module/foo‘, // -> this[‘some/nested/module/foo‘]() ‘some/nested/module/bar‘ // -> this[‘some/nested/module/bar‘]() ])
简写带空间名称的字符串
...mapActions(‘some/nested/module‘, [ ‘foo‘, // -> this.foo() ‘bar‘ // -> this.bar() ])
1 import { createNamespacedHelpers } from ‘vuex‘ 2 3 const { mapState, mapActions } = createNamespacedHelpers(‘some/nested/module‘) 4 5 export default { 6 computed: { 7 // 在 `some/nested/module` 中查找 8 ...mapState({ 9 a: state => state.a, 10 b: state => state.b 11 }) 12 }, 13 methods: { 14 // 在 `some/nested/module` 中查找 15 ...mapActions([ 16 ‘foo‘, 17 ‘bar‘ 18 ]) 19 } 20 }
原文:https://www.cnblogs.com/it-Ren/p/10785368.html