The problem of changing the properties of the object and not refreshing the view in the vue component

when an object collocateval, is defined in vue"s data data center and properties are added or modified to collocateval when an event is triggered, the view on the page will not be updated by Synchronize, but will be updated by Synchronize only when other data has changed
code is as follows:

Ask God to tell me whether

clipboard.png
vue.set

clipboard.png

vue
clipboard.png
is written incorrectly in the component.

Mar.04,2021

Vue is based on Object.defineProperty and implements almost painless state listening by replacing the attribute with getter/setter. This process occurs when the component is initialized, and the properties of all the variables you define are replaced.

so if you assign a value after the instantiation is complete, it's really just an assignment, not a call to setter, so you lose the response.

The

solution is to use Vue.set, or assign the entire object.


this.collocateval = {state: 1}
Menu