How does vuex store the value?

if you read the vuex, you will take the value, but will not save the value. The boss can give a small demo to learn. Thank you

.
Mar.04,2022

store.js:
state: {

value:''

}

mutations: {

changeValue(state,newVal){
    state.value=newVal
}

}
.vue:


//
this.$store.commit('changeValue',1)
//
console.log(this.$store.state.value)//1


If there is a method in mutations,mutations in

vuex, you can submit the value of store

official text:
the only way to change the state in the store of Vuex is to submit the mutation. Mutation in Vuex is very similar to events: each mutation has an event type (type) of a string and a callback function (handler). This callback function is where we actually make the state change, and it accepts state as the first parameter:

const store = new Vuex.Store({
  state: {
    count: 0
  },
  mutations: {
    increment (state) {
      state.countPP
    }
  },
  actions: {
    increment (context) {
      context.commit('increment')
    }
  }
})

ide/mutations.html" rel=" nofollow noreferrer "> Mutation


you might as well take a look at my to learn Vuex from scratch , which introduces an implementation of digital self-increasing and self-decreasing demo, and how to transform this small demo, with vuex source code is complete, very suitable for beginners! I hope it will help you!

clipboard.png


vuexstoredispatchactioncommithttps://vuex.vuejs.org/zh/

vuex.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c402-4ef62.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c402-4ef62.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?