[Uni app] pit

1.vuex can not be used directly in the template (can be used in a script)

<view class="nickname">{{$store.state.userInfo.nickname}}</view>

Get not shown above, the solution: compoted is introduced in the current vue like mapState

computed: {
  ...mapState(['userInfo']),
  ...mapGetters(['hasLogin'])
},

template can be directly read as follows

<view class="nickname">{{userInfo.nickname}}</view>

  

Guess you like

Origin www.cnblogs.com/Mijiujs/p/12511707.html