Data binding of v-model instruction when vue uses vuex

data binding of v-model instructions when vue uses vuex

there are two ways to write it. I"d like to ask you some of the differences.

method one
computed: {
    name: {
        get() {
          return this.$store.state.name
        },
        set(v) {
          // vuexmutations
          this.$store.commit("name", v)
        }
    }
}

so are these two writing methods feasible?

May.10,2021

the two are different. There is no testing, but the data of store can only be changed through commit . Method 2 should be feasible, but method 1 is not.
official document
ide/mutations.html" rel=" nofollow noreferrer "> https://vuex.vuejs.org/zh/gui.


here is rarely used in actual projects (not to say which is possible), since your application scenario with vuex is multiple peer components, or data sharing in routing. There are usually multiple store. Most projects use modules, and then use map in components.

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-1ea8d94-1f02.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-1ea8d94-1f02.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?