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

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

han32686年前 (2020-07-30)VUE13954

做项目时需要用到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]); //选中已选中节点
    },







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

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

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

分享给朋友:

相关文章

vue中实现点击按钮滚动到页面对应位置 使用css3平滑属性实现

vue中实现点击按钮滚动到页面对应位置 使用css3平滑属性实现

vue项目中,需要实现点击对应按钮,滚动到对应页面位置,下面分享一个简单实用的方法<template>   <div class="box&...

vue element table expand 设置只可以展开一行、设置点击行即可打开扩展内容

在Vue中使用Element UI的el-table组件时,‌可以通过以下步骤设置只可以展开一行以及通过点击行即可打开扩展内容:‌设置只可以展开一行:‌通过监听expand-change事件来实现每次...

基于Vue的移动端图片裁剪组件(vue-imgcut)

基于Vue的移动端图片裁剪组件(vue-imgcut)

安装:npm install vue-imgcut –save使用代码:<template>     <div...

vue 去除前后空格trim的使用方法

一、使用trim修饰符<input v-model.trim = "massage" >二、使用filter过去属性 <...

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

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