PanJiaChen / vue-element-admin

:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
MIT License
88k stars 30.48k forks source link

this.$store.getters 问题 #837

Closed moonose closed 6 years ago

moonose commented 6 years ago

我在user.js里GetUserInfo 函数里设置了state下的几个参数

      commit('SET_CODE', data.code)
      commit('SET_USER', data.sam)
      commit('SET_NAME', data.name)

很奇怪我在其他页面里用

    console.log(this.$store.getters.code);
    console.log(this.$store.getters.user);
    console.log(this.$store.getters.roles);
    console.log(this.$store.getters.name);

只有 roles和name有值,code和user都没有,这是啥情况?

PanJiaChen commented 6 years ago

https://github.com/PanJiaChen/vue-element-admin/blob/master/src/store/getters.js

请自行看vuex文档。