How to get the value of computed in methods

computed: {
    perssionObj() {
        return this.$store.state.permission
    },
}

perssionObj can get a value in template,
but what you get in methods is undefined. What"s going on with this?

Dec.09,2021

just this.perssionObj


computed attributes are cached based on their dependencies. They are re-evaluated only when the relevant dependencies change. This means that as long as the this.$store.state.permission has not changed, accessing the perssionObj calculation property will immediately return the previous calculation result, you get the undefined. So look at the problem with your this.$store.state.permission initialization.

Menu