My project was developed by Vue js and it has store developed by javascript, and I integrated new component which is developed by vue-typescript and all scripts in this components are developed by typescript.
To import state variable, I tried two ways
use Vuex
import { mapGetters, mapState, mapActions, mapMutations, createNamespacedHelpers } from 'vuex'
@Component({
computed: {
...mapState([
'allowedUrls'
])
}
})
this case this.allowedUrls
is not defined error
Use Vuex-Class
import { State } from 'vuex-class'
@State allowedUrls: string[]
this case, this.allowedUrls
is always undefined
How can I fix this problem?
this.allowedUrls
? If in theconstructor
,allowedUrls
would not have been initialized yet. – tony19