|
@@ -118,7 +118,7 @@
|
|
} else {
|
|
} else {
|
|
hasChild = Math.random() > 0.5;
|
|
hasChild = Math.random() > 0.5;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
setTimeout(function() {
|
|
setTimeout(function() {
|
|
let data;
|
|
let data;
|
|
if (hasChild) {
|
|
if (hasChild) {
|
|
@@ -130,7 +130,7 @@
|
|
} else {
|
|
} else {
|
|
data = [];
|
|
data = [];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
resolve(data);
|
|
resolve(data);
|
|
}, 500);
|
|
}, 500);
|
|
},
|
|
},
|
|
@@ -161,11 +161,11 @@
|
|
append(store, data) {
|
|
append(store, data) {
|
|
store.append({ id: id++, label: 'testtest', children: [] }, data);
|
|
store.append({ id: id++, label: 'testtest', children: [] }, data);
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
remove(store, data) {
|
|
remove(store, data) {
|
|
store.remove(data);
|
|
store.remove(data);
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
renderContent(h, { node, data, store }) {
|
|
renderContent(h, { node, data, store }) {
|
|
return (
|
|
return (
|
|
<span>
|
|
<span>
|
|
@@ -178,13 +178,13 @@
|
|
</span>
|
|
</span>
|
|
</span>);
|
|
</span>);
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
filterNode(value, data) {
|
|
filterNode(value, data) {
|
|
if (!value) return true;
|
|
if (!value) return true;
|
|
return data.label.indexOf(value) !== -1;
|
|
return data.label.indexOf(value) !== -1;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
data,
|
|
data,
|
|
@@ -200,7 +200,7 @@
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
-## Tree
|
|
|
|
|
|
+## Tree
|
|
|
|
|
|
Display a set of data with hierarchies.
|
|
Display a set of data with hierarchies.
|
|
|
|
|
|
@@ -452,7 +452,7 @@ Tree nodes can be initially expanded or checked
|
|
this.$refs.tree.setCheckedKeys([]);
|
|
this.$refs.tree.setCheckedKeys([]);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
data2: [{
|
|
data2: [{
|
|
@@ -518,7 +518,7 @@ The content of tree nodes can be customized, so you can add icons or buttons as
|
|
|
|
|
|
<script>
|
|
<script>
|
|
let id = 1000;
|
|
let id = 1000;
|
|
-
|
|
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -563,16 +563,16 @@ The content of tree nodes can be customized, so you can add icons or buttons as
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
methods: {
|
|
methods: {
|
|
append(store, data) {
|
|
append(store, data) {
|
|
store.append({ id: id++, label: 'testtest', children: [] }, data);
|
|
store.append({ id: id++, label: 'testtest', children: [] }, data);
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
remove(store, data) {
|
|
remove(store, data) {
|
|
store.remove(data);
|
|
store.remove(data);
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
renderContent(h, { node, data, store }) {
|
|
renderContent(h, { node, data, store }) {
|
|
return (
|
|
return (
|
|
<span>
|
|
<span>
|
|
@@ -777,8 +777,8 @@ Only one node among the same level can be expanded at one time.
|
|
| filter | filter all tree nodes, filtered nodes will be hidden | Accept a parameter which will be used as first parameter for filter-node-method |
|
|
| filter | filter all tree nodes, filtered nodes will be hidden | Accept a parameter which will be used as first parameter for filter-node-method |
|
|
| getCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes | Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
|
| getCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes | Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
|
| setCheckedNodes | set certain nodes to be checked, only works when `node-key` is assigned | an array of nodes to be checked |
|
|
| setCheckedNodes | set certain nodes to be checked, only works when `node-key` is assigned | an array of nodes to be checked |
|
|
-| getCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of node's keys | (leafOnly) Accept a boolean type parameter whose default value is `true`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
|
|
|
-| setCheckedKeys | set certain nodes to be checked, only works when `node-key` is assigned | (keys, leafOnly) Accept two parameters: 1. an array of node's keys to be checked 2. a boolean type parameter whose default value is `true`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
|
|
|
|
|
+| getCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of node's keys | (leafOnly) Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
|
|
|
+| setCheckedKeys | set certain nodes to be checked, only works when `node-key` is assigned | (keys, leafOnly) Accept two parameters: 1. an array of node's keys to be checked 2. a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
|
|
| setChecked | set node to be checked or not, only works when `node-key` is assigned | (key/data, checked, deep) Accept three parameters: 1. node's key or data to be checked 2. a boolean typed parameter indicating checked or not. 3. a boolean typed parameter indicating deep or not. |
|
|
| setChecked | set node to be checked or not, only works when `node-key` is assigned | (key/data, checked, deep) Accept three parameters: 1. node's key or data to be checked 2. a boolean typed parameter indicating checked or not. 3. a boolean typed parameter indicating deep or not. |
|
|
|
|
|
|
### Events
|
|
### Events
|
|
@@ -789,4 +789,3 @@ Only one node among the same level can be expanded at one time.
|
|
| current-change | triggers when current node changes | two parameters: node object corresponding to the current node, `node` property of TreeNode |
|
|
| current-change | triggers when current node changes | two parameters: node object corresponding to the current node, `node` property of TreeNode |
|
|
| node-expand | triggers when current node open | three parameters: node object corresponding to the node opened, `node` property of TreeNode, TreeNode itself |
|
|
| node-expand | triggers when current node open | three parameters: node object corresponding to the node opened, `node` property of TreeNode, TreeNode itself |
|
|
| node-collapse | triggers when current node close | three parameters: node object corresponding to the node closed, `node` property of TreeNode, TreeNode itself |
|
|
| node-collapse | triggers when current node close | three parameters: node object corresponding to the node closed, `node` property of TreeNode, TreeNode itself |
|
|
-
|
|
|