[Vuejs]-Vuex- Page is not updating after commit changes made to state

0👍

Add getters to your store:

export const getters= {
   getMessages: state => state.messages
}

and then use the getters in your component instead of accessing the state directly:

// read.vue
<script>
import {mapGetters} from 'vuex'

  export default {
    data() {
      return {}
    },
    computed:{
      ...mapGetters({
          messages: 'getMessages',
      })
    }
  }
</script>

Leave a comment