Does import mapGetters have any path requirements in vue? Why do sublevel directories see undefined?

use
src/views/xxx/index.vue

here

import {mapGetters} from "vuex"
computed: {

...mapGetters([
  "user_id",
  "username",
])

},

this.username can be printed in created

the same code is put in
src/views/xxx/yyy/index.vue
print this.username becomes undefined

Mar.07,2021

there is no problem in theory. Could it be that your username getter itself does not have data


how your store file is referenced? it should be the wrong path referenced by store. src/views/xxx/yyy/index.vue the store reference in this file should also be looked up one more level

Menu