Can anyone tell me what the store of vue is? It's best to have a demo.

the official website is too simple.

/ / store.js

export default {
    state : {
        count : 20
    },
    addsome (num) {
        this.state.count = this.state.count+Number(num)
    }
}

/ / component.js

<template>
    <div id="header">
        <button @click="add"></button>
        

{{initState2}}

</div> </template> <script> import store from "../../vuex/storeModule" name : "home", data () { return { initState: store.state.count } } methods : { add () { store.addsome(202) } } </script> button
Mar.05,2021

initState: store.state.count change here to store.state, like initState and store.state point to the same object, and when you change store.state, the initState will change. Writing initState: store.state.count like this is actually equivalent to: initState:20, has nothing to do with store objects.
personally, the store mode is similar to the simplified version of flux, while vuex is similar to the simplified version of reduce.


to learn about vuex, first look at the flux concept of facebook, and then look at the concept of redux. Vuex is equivalent to redux


http://vuex.vuejs.org/zh-cn/intro.html
in vue. It is suggested that the event


addsome should be put in mutations, and then actions will dispatch the event.
take a closer look at the main document.
http://vuex.vuejs.org/zh-cn/mutations.html


you can refer to my article. Store mode is very useful, but it's a pity that I answered too late

.

https://juejin.im/post/5cd508.


https://github.com/papersnake/newdenfaces-vue
is constantly updating. I will update my series of articles after the code has been written. However, I have just come into contact with VUE+VUEX+VUE-ROUTER, so please give us some advice on the wrong places to use it.


what you want is the use of store mode. Why do you say vuex


http://www.jb51.net/article/1. store's perfect answer

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