Recently using the VUE2.0 development project, there is a list that uses v-for to bind to an array, using the push, splice, this, and so on Vue's recommendation. $set three mutation methods to manipulate the array. Found in the Add page, three methods will be able to refresh the view in a timely manner, but in the modified page, only this. $set method to modify the array elements can be refreshed, the other two methods do not refresh the view, using Vue-devtools view, the data can be successfully modified.
Try to use the push method in the Mount phase to add one by one, try to use the object to display the definition field properties, try Baidu to the N method ... It took four or five hours, no! But the problem must be that there is no condition that triggers the Vue refresh view.
Finally, a manual forced refresh is simulated:
1. Add a hidden to the HTML and bind to a flag field:
2. The Mount stage assigns the initial value to flag:
3. After push and splice, change the value of flag!!!
Idea: Because flag is a simple field, its change is sure to refresh the view, so by changing the flag, manually refresh the view.
Thus, the view refresh of Vue is a whole refresh, not just the changed fields.
Vue array operation does not refresh the resolution of the view problem