0👍
Try adding set
and get
property:
const user = computed({
get: store.state.user,
set: (val) => store.state.user = val
});
0👍
Try using a getter instead acessing the value directly in the state
Getter for user:
export function getUser(state){
return state.getUser
}
and in the component import the getter like this:
<script>
import {mapGetters} from 'vuex'
export default {
computed: {
...mapGetters('*theStoreName*',['getUser'])
},
watch: {
getUser: function(){
//Should be possible to see when the getUser changes here
console.log(this.getUser)
}
}
}
</script>
Note: You have theStoreName for the store name you’re using
Maybe the problem is that the store name is missing, or when you did store.state.user
you’re acessing the store? If it is it, then you should try to inform the variable you’re trying to access, like If it is, like store.state.user.name
, with the getter it would be: getUser.name
- [Vuejs]-Blank Page with Vuejs and Laravel
- [Vuejs]-This expression is not callable for vue 2 with composition api and class component
Source:stackexchange.com