文章详情页
javascript - ...mapGetters和...mapState获取到的state,怎么拿来在methods中操作?
浏览:54日期:2023-09-07 16:35:52
问题描述
只能页面中展示的吗?我知道用this.$store.state可以获取这些state来操作
问题解答
回答1:...mapState({a: function (state) { return state.A},b: function (state) { return state.b} })
在其他方法中直接访问this.a this.b即可
回答2:直接用比如...mapState([’changePrePosition’])用的时候直接用this.changePrePosition()就行了
回答3:...mapState([’value’])
使用this.value就可以取到值了,但是修改state的值需要经过mutations
标签:
JavaScript
排行榜
