The use of vuex state tree

 export const state = () => ({
   wishNum: 0
  });
 export const mutations = {
  SET_WISH: (state) => {
     state.wishNum = 0;
 },
}

 let Num = res.total;
 setStore("wishNum", Num);

-sharp-sharp
whether I am writing this correctly. I can"t get the value of $store.state.user.wishNum. The local value is changing, but it"s still 0.

Apr.24,2021

is not $store.state.wishNum?


are state and mutations in the same file?
you can write state.js separately

export default {
    wisNum: 0
}

mutations.js

export default {
    SET_WISH: (state, payload) => {
        state.wishNum = payload
    }
}

in index.js

import state from './state.js'
import mutations from './mutations.js'
export default new Vuex.Store({
    state, mutations
})

in the Vue component

this.$store.commit('SET_WISH', 12)

in main.js

import store from './store/index.js'
new Vue({
  el: '-sharpapp',
  router,
  components: { App },
  template: '<App/>',
  store
})
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-1bf00d3-3a084.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-1bf00d3-3a084.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?