Initialize an array in vue watch. The view cannot respond after the properties in the array object are changed.

jsfiddle

initialize the newVal array with map so that it has one more attribute b than the value array, but there is no response on the view when the b attribute is changed. You can change the following code in the watch method to take effect

const arr = newVal.map(item => {
    item.b = true;
    return item;
})
this.newVal = JSON.parse(JSON.stringify(arr))

but didn"t array.prototype.map generate a new array? why didn"t the b attribute add watch

Mar.31,2021
Menu