Data Monitoring and Storage in vuex

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?

May.22,2021

Hello, do you encounter this problem on a single-page application project (front-end routing) or on a traditional multi-page project (back-end routing)?

if it is the former, then according to the responsive principle of vuex, there is no need to do any monitoring operation, and it is used for state management, which can store part of the data related to the interaction and, of course, all the data (but not necessary).

if it is the latter, then the store of each page is supposed to be independent and seems to require some external storage.

Menu