SoFunction
Updated on 2025-04-05

Solve the problem that vuex changed the value of state but the page did not update

When the attribute in state is defined as obj type, sometimes it appears: after other pages have modified the state value, other pages are not updated synchronously.

This is when you need to change it. ((obj))

this.$("setGlobalUserInformation",((obj)))

Supplementary knowledge:A "error" vuex writing method: vuex refreshes data but view is not refreshed

This is a very embarrassing question, let me guess if your code is written like this:

<template>
 <div >
 <img src="./assets/">
 <button @click="clickme">Click me</button>
 <span>{{countnumber}}</span>
 </div>
</template>
<script>
 export default {
 name: 'app',
 data() {
  return {
  countnumber: this.$,
  }
 },
 methods: {
  clickme: function() {
  this.$("increment");
  }
 },
 }
</script>
<style>
 
</style>

Then congratulations, no matter how bright you are, it will be 0. But if you write the following way, it is correct:

<template>
 <div >
 <img src="./assets/">
 <button @click="clickme">Click me</button>
 <span>{{$}}</span>
 </div>
</template>
<script>
 export default {
 name: 'app',
 data() {
 },
 methods: {
  clickme: function() {
  this.$("increment");
  }
 },
 }
</script>
<style>
 
</style>

The difference is that you directly associate it into the interface. Why is this? I don't know, after all, it's someone else's framework.

The above article solves the problem that vuex has changed the value of state, but the page is not updated. This is all the content I share with you. I hope you can give you a reference and I hope you support me more.