当前位置:首页 > 经验笔记 > VUE > 正文内容

element-ui Tree 树形控件实现单选 最简方法VUE

han32686年前 (2020-07-30)VUE14072

做项目时需要用到Tree树形控件单选但是Tree组件没有单选设置,网上找了几个方法不太适应,看了官网文档发现很简单 代码如下

          <el-tree
            ref="treeForm"
            default-expand-all
            node-key="id"
            :data="findCapitalAreasData"
            :props="defaultProps"
            show-checkbox
            :check-strictly="true"
            @check="handleCheckChangeArea"
          ></el-tree>
    //当复选框被点击的时候触发
    handleCheckChangeArea(data) {
      var labvalojb = data; //暂存选中节点
      // console.log(data);
      this.$refs.treeForm.setCheckedKeys([]); //删除所有选中节点
      this.$refs.treeForm.setCheckedNodes([labvalojb]); //选中已选中节点
    },







扫描二维码推送至手机访问。

版权声明:本文由瀚文博客发布,如需转载请注明出处。

本文链接:https://www.hanwenblog.com/post/20.html

分享给朋友:

相关文章

vue 项目运行node-sass报错

vue 项目运行node-sass报错

报错信息Browserslist: caniuse-lite is outdated. Please run:   npx&nb...

vue强制更新$forceUpdate()

vue强制更新$forceUpdate()

vue强制更新$forceUpdate()添加this.$forceUpdate();进行强制渲染,效果实现。搜索资料得出结果:因为数据层次太多,render函数没有自动更新,需手动强制刷新。调用强制...

vue 弹框使用this.$emit调用父组件方法及传参 无效 (已解决) this.$parent

// 在子组件中调用父组件的method1方法 this.$parent.method1() // 获取父组件属性值 this.$parent.prop...

VUE computed和watch的区别最简化

VUE computed和watch的区别最简化

<!DOCTYPE html> <html lang="en"> <head>    &...

在vue中实现element-ui的el-dialog弹框拖拽

1.在assets/js/文件夹下新建directives.js 文件:import Vue from 'vue' // v-dialog...