element-ui tree树形控件单个选择节点
2019-02-15 16:57
316 查看
element-ui tree控件单个选择节点
element-ui tree怎么选择单个叶子节点的解决方案。实现的效果如下:
废话不多说,上代码(如下图):
html:
<div class="recursionTree" v-if="showHierarchy"> <el-tree :data="data2" :props="defaultProps" ref="tree" :expand-on-click-node="false" node-key="id" :default-expanded-keys="[bbb]" :highlight-current="true" :check-on-click-node="true" @node-click="handleNodeClick"> </el-tree> </div>
js:
onChangeBlur () { this.showHierarchy = !this.showHierarchy; if (this.showHierarchy) { // true 是展开 tree选择项 this.$nextTick(function () { this.$refs.tree.setCurrentKey(this.bbb) }) } }, handleNodeClick(data) { this.aaa = data.label;// 当前选中的名称 this.bbb = data.id; // 当前选中id this.showHierarchy = false; }
数据结构:
data2: [ { // 编辑新增 tree id: 1, label: '一级 1', children: [{ id: 11, label: '二级 1-1', children: [{ id:111, label: '三级 1-1-1' }] }] }, { id: 2, label: '一级 2', children: [{ id: 21, label: '二级 2-1', children: [{ id: 211, label: '三级 2-1-1' }] }, { id: 22, label: '二级 2-2', children: [{ id:221, label: '三级 2-2-1' }] }] }, { id: 3, label: '一级 3', children: [{ id:31, label: '二级 3-1', children: [{ id:311, label: '三级 3-1-1' }] }, { id:32, label: '二级 3-2', children: [{ id:321, label: '三级 3-2-1' }] }] }]
整体代码就是这样了,有遇到和我一样问题的小伙伴可以参考哦~
相关文章推荐
- vue中element-ui树形控件自定义节点,注意一下
- vue.js element-ui tree树形控件改iview的方法
- [原创]vue+element-ui之tree树形控件有关子节点和父节点之间的各种选中关系详解
- vue elementUI tree树形控件获取父节点ID的实例
- TreeView 控件客户端节点选择的代码
- Element-Ui组件(二十五)Tree 树形控件
- TreeView控件结合js树形选择
- [置顶] MFC树形控件CTreeCtrl使用方法、遍历、SetCheck无效、根据名称获取节点、获取选中节点等问题
- 打造自己地图AxTOCContrl树形控件——XUTocControl(成功解决节点控件拖拽问题)
- 树形控件复选框的级联选择
- asp.net treeview控件无刷新选择和删除节点(使用jquery)
- VC对话框中树形控件节点编辑响应回车事件完成编辑
- JSF点滴积累--Tree2控件的树节点的默认选择
- Android笔记--仿拖动选择日期时间控件的单个item
- 为树形控件添加弹出式菜单,并跟踪所选择的项
- element时间控件控制选择范围
- Qt树形控件QTreeView使用1——节点的添加删除操作 复选框的设置
- Element-ui tree组件自定义节点使用方法代码详解
- 基于单个对话框工程中,CListBox控件上实现 选择/复制功能(不要写CListBox的派生类)
- asp.net treeview控件无刷新选择和删除节点(使用jquery)