Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 25d43b3

Browse files
fix: selectedNodes to checkedNodes
1 parent c670098 commit 25d43b3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

‎src/components/Tree.js‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,22 @@ export default {
7171
allowDrop: true,
7272
isInitData: false
7373
},
74-
checkedNodes: [],
75-
checkedNodeKeys: [],
76-
selectedNodes: []
74+
checkedNodes: []
7775
}
7876
},
7977
created() {
8078
this.initData(); //init
81-
console.log(this.checkedNodeKeys)
82-
console.log(this.checkedNodes)
8379

8480
},
8581
methods: {
8682
initData(root = this.root) {
87-
const selectedNodes = []
88-
this.recurTree(root, selectedNodes)
89-
selectedNodes.forEach((node) => {
83+
const checkedNodes = []
84+
this.recurTree(root, checkedNodes)
85+
checkedNodes.forEach((node) => {
9086
this.refreshUp(node)
9187
this.refreshDown(node)
9288
})
93-
this.recurTree(root, this.selectedNodes)
89+
this.recurTree(root, this.checkedNodes)
9490
},
9591
recurTree(node, db){
9692
if(node.isSelected()){
@@ -107,14 +103,12 @@ export default {
107103
},
108104
getCheckedValue (node) {
109105
if (!node.data.id) return
110-
const index = this.checkedNodeKeys.findIndex(item => item === node.data.id)
106+
const index = this.checkedNodes.findIndex(item => item === node)
111107
if (node.isSelected() || (this.hasHalfelEction && node.isPartialSelected())) {
112108
if (index < 0){
113-
this.checkedNodeKeys.push(node.data.id)
114109
this.checkedNodes.push(node.data)
115110
}
116111
} else if (index >= 0) { // 当前的节点 !(选中 || 半选) && exist
117-
this.checkedNodeKeys.splice(index, 1)
118112
this.checkedNodes.splice(index, 1)
119113
}
120114
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /