whether 1.vuex can be used to store data or whether it is used to store data itself.
for example, page An and B2 make ajax requests on page A, and the data obtained need to be displayed on page B. My personal approach is to store the ajax data in state, and then the B page will call the data in state. This method has been tried to work, but I don"t know if it makes sense, or vuex itself is used to do this.
2. How to listen for changes in data in vuex. The button on the
A page controls the display of the div on page B. the easiest way is to add the @ click event to the button on page An and submit the click event to Mutations. Change a variable in state to false, page B to listen to this variable, and if the variable changes, the div will be hidden.
B
export default{
data(){
ishow=true
},
computed:{
...MapState(["x"])
},
watch:{
x(){
this.ishow=this.x
//
this.ishow=!this.ishow
}
my current implementation is still by listening to whether the introduced variables have changed, and if so, changing the ishow, thus controlling the display and hiding of the div. But if there are 10 or more pages or components that need to listen for x changes. I need to write and monitor every page or component. Is there any other way to change the state of a page or component div by changing state?