go straight to the code:
//
const tree = {
state: {
allNode: [],
treeNode: null
},
mutations: {
SET_ALL_NODE: (state, keys) => {
state.allNode = [...keys];
},
SET_TREE_NODE: (state, nodes) => {
state.treeNode = [...nodes];
}
},
actions: {
async GetAllNode({commit}){
commit("SET_ALL_NODE", keys);
return keys;
},
async GetTreeNode({commit}, nodes) {
commit("SET_TREE_NODE", nodes);
return nodes;
}
}
}
export default tree;
//
async getallTree() {
let allData = store.state.tree.allNode;
for (let item of allData) {
item["disabled"] = true;
}
this.menuData = [...store.state.tree.treeNode];
}
what I modify directly is allData
why the allNode
and treeNode
corresponding states are filled with the disabled
attribute.