avue-tree树型控件全选/全不选用法一例

avue-tree树型控件全选/全不选用法一例

显示效果:
在这里插入图片描述

Vue界面html脚本

<template>
  <div>
    <el-button type="primary" @click="checkALL">全选/全不选</el-button>
    <el-button type="primary" @click="save"
      style="left: 200px; top: 20px; position: absolute; z-index:9999">保存</el-button>
    <avue-tree ref="menuTree" :option="option" :data="treeData"   multiple
         v-model="form" @check-change="checkChange" class="width:100%,height:calc(100% - 40px);">
    </avue-tree>
 </div>
</template>

Vue界面javascript脚本

data() {
    
    
    return {
    
          
      treeData:[],
      isALLCheck:false,
      //      
      option: {
    
    
        defaultExpandAll: true,
        multiple: true,
        filter: false,
        menu: false,
        formOption: {
    
    
          labelWidth: 100,
          column: [{
    
    
            label: '自定义项',
            prop: 'label'
          }, {
    
    
            label: '测试',
            prop: 'test'
          }],
        }
      }
    }
  },
    /**
     * 全选/全不选
     */
    checkALL()
    {
    
    
      //console.log('menuTree',this.$refs.menuTree);      
      this.isALLCheck=!this.isALLCheck;
      var data=this.$refs.menuTree.data;      
      for(var i=0;i<data.length;i++)
      {
    
    
         this.$refs.menuTree.setChecked(data[i],this.isALLCheck,true);         
      }
    },
    /**
     * 保存功能
     */
    save() {
    
    
      var that = this;
      //
      this.roleId;
      debugger
      //
      console.log('menuTree',this.$refs.menuTree);
      var data=this.$refs.menuTree.getCheckedNodes();
      for(var i=0;i<data.length;i++)
      {
    
    
         var checked=data[i];
         console.log(checked);
      }
      //
    },

—the—end—

猜你喜欢

转载自blog.csdn.net/hsg77/article/details/129264040