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
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47947-43bbf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47947-43bbf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?