其他分享
首页 > 其他分享> > vue获取访问vuex分模块的数据

vue获取访问vuex分模块的数据

作者:互联网

1、传统方法

this.$store.state['模块名']['属性名']

2、mapState方法:

import { mapState } from 'vuex'
computed: {
    // ...
    ...mapState({
      list: state => state.city.list
    })
  }

触发其他模块的action
1、

this.$store.dispatch('模块名/属性名', opts)

标签:...,vue,mapState,state,模块,vuex,store
来源: https://blog.csdn.net/qq_45351419/article/details/121339773