For example code:
The first step: Get a data object array from the server: [obj, obj, obj],
The second step: Add a browser object obj to each sub-object:
for(let i = 0; i
Step 3: Bind this attribute to the html structure to control the dynamic class
html: - qwer
js: methods: { changeBg(item){ item.myObj = true } } css: .change_bg background: red
The result is: the myobj attribute has been changed to true each time it is clicked, but the dynamic class will not take effect until ul is refreshed (when refreshed, the ul data will not be reacquired).
Correct answer upstairs. Because the attribute is added dynamically, you need to use the set method provided by vue to make the attribute an ES5 accessor attribute to track changes.