下載的ztree組件,單獨打開是好用的,放到專案里面就爆炸了呢。孩子有點蒙蔽。
搜索框爆炸啦

uj5u.com熱心網友回復:
推薦element組件:https://element.eleme.io/#/zh-CN/component/tree試試人家的組件:
<el-input
placeholder="輸入關鍵字進行過濾"
v-model="filterText">
</el-input>
<el-tree
class="filter-tree"
:https://bbs.csdn.net/topics/https://bbs.csdn.net/topics/data="data"
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
ref="tree">
</el-tree>
<script>
export default {
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
methods: {
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
}
},
data() {
return {
filterText: '',
data: [{
id: 1,
label: '一級 1',
children: [{
id: 4,
label: '二級 1-1',
children: [{
id: 9,
label: '三級 1-1-1'
}, {
id: 10,
label: '三級 1-1-2'
}]
}]
}, {
id: 2,
label: '一級 2',
children: [{
id: 5,
label: '二級 2-1'
}, {
id: 6,
label: '二級 2-2'
}]
}, {
id: 3,
label: '一級 3',
children: [{
id: 7,
label: '二級 3-1'
}, {
id: 8,
label: '二級 3-2'
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
};
}
};
</script>
uj5u.com熱心網友回復:
謝謝看著功能比較全
uj5u.com熱心網友回復:
那就請采納吧!結帖
uj5u.com熱心網友回復:
查了一下要用VUE,我又不會VUE啊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/280878.html
標籤:JavaScript
上一篇:離線下載功能怎么實作?
