Answer the question
In order to leave comments, you need to log in
How to update the data on the page when updating the data in the store?
I receive data from a websocket in store:
store.js :
state: {
socket: {
isConnected: false,
message: '',
wsData: {},
reconnectError: false,
}
}
mutations: {
...
SOCKET_ONMESSAGE (state, message) {
...
let d = JSON.parse(message.data);
console.log(d);
state.socket.wsData = d;
...
}
...
<template>
<div>
<p> {{ d.someData }} </p>
</div>
</template>
...
methods: {
sendCalculation() {
this.$socket.send(dataToServer);
},
}
...
computed: {
d(){
return this.$store.state.socket.wsData;
}
},
...
this.$forceUpdate();
but no effect. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question