Real dom problem in vue rendering

html:
<div id="test">
    <input type="button" @click="fn1()">{{arr["x"]}}
    <input type="button" @click="fn2()">{{arr["y"]}}
</div>
js:
 data: {
    arr: ["x", "y"],
    z: 5
},
        
fn2() {
    Vue.set(this.arr, "y", PPthis.arr["y"]);
    // PPthis.z;
    console.log(this.arr);
}
// PPthis.z domarr
Apr.25,2022

you have to change arr into an object instead of an array


Why does the statement PPz achieve the effect of forceupdate, and does it re-render the entire object?


Vue.set (this.arr, 1, PPthis.arr [1]);


according to your entanglement, the answer has been given on vue's official website as follows:

due to the limitation of JavaScript, Vue cannot detect the array with the following changes:
when you directly set an item in the array using the index, for example: vm.items [indexOfItem] = newValue
when you modify the length of the array, for example: vm.items.length = newLength, the array will not be updated.

solution in vue:

 Vue.set, vm.$set(Vue.set) splicecaoncat
Menu