Doray
Doray
  • 发布:2019-11-27 11:43
  • 更新:2019-11-27 11:51
  • 阅读:3520

在uniapp里面使用vuex state获取不到???

分类:uni-app

<view class="user_name">{{$store.state.userName}}</view>
在tempalte里面直接获取不到吗?
在js里面 使用this.$store.state.userName 就能获取到啊。

2019-11-27 11:43 负责人:无 分享
已邀请:
6***@qq.com

6***@qq.com

computed: {
// 使用对象展开运算符将 getters 混入 computed 对象中
...mapGetters([
'countDouble',
'CountDoubleAndDouble',
//..
])

  • Doray (作者)

    多谢!!!

    2019-11-27 11:56

6***@qq.com

6***@qq.com

computed: {
count: function(){
return this.$store.state.count
},
countDouble: function(){
return this.$store.getters.countDouble
},
countDoubleAndDouble: function(){
return this.$store.getters.countDoubleAndDouble
}
},

  • Doray (作者)

    哦哦哦哦哦 意思就是不能直接在模板里面是用呗, 谢谢

    2019-11-27 11:56

  • 6***@qq.com

    回复 Doray: 是的

    2019-11-28 11:29

该问题目前已经被锁定, 无法添加新回复