Can listen to:

arr.push()

arr.splice()

No listening:

Arr [1] = 5 when the index sets an item directly

Method one:

Array methods such as arr.push() and arr.splice() are used to modify arrays

Such as:

/ / modify

let oldMenuList = this.$store.getters.get_menu_info;

let pathIndex = pathArr.indexOf(path);

let editItem = oldMenuList[pathIndex];

editItem.active = true;

oldMenuList.splice(pathIndex, 1, editItem);

this.$store.commit('set_menu_list', oldMenuList);
Copy the code
/ / assignment

let selectItem = {
    title,
    path,
    active: true};let oldMenuList = this.$store.getters.get_menu_info;

oldMenuList.push(selectItem);

this.$store.commit('set_menu_list', oldMenuList);
Copy the code
/ / to monitor

'$store.getters.get_menu_info': function (newVal) {
    console.log(newVal)
},
Copy the code

Method 2:

Parse (json.stringify (arr)) after converting an array to a string. Parse (json.stringify (arr)) when converted to an array and converted to a string when modified;