el-tree动态禁用状态

<template>
    <div class="hello">
        <h1>{{ msg }}</h1>
        <el-tree
                accordion
                show-checkbox
                :data="testOrgList1"
                style="display: flex;flex-direction: column;margin-left: 20px"
                v-model="CHOOSE_ORG_NAME"
                :props="defaultProps"
                @change="handleChange"
                @node-click="handleNodeClick">
        </el-tree>
    </div>
</template>

<script>
    export default {
        name: 'HelloWorld',
        props: {
            msg: String
        },
        data(){
             return{
                 CHOOSE_ORG_NAME: '',
                defaultProps: {
                    children: 'children',
                    label: 'ORG_NAME',
                    disabled:this.disFn
                },
                orgno:"03001",
                 testOrgList1: [
                     {
                         'ORG_NAME': '01数据一','label': '01数据一', 'ORG_NO': '01001','ORG_TYPE': '01', 'P_ORG_NO': '', children: [
                             {
                                 'ORG_NAME': '03数据一','label': '03数据一',  'ORG_NO': '03001','ORG_TYPE': '03', 'P_ORG_NO': '01002'
                             }
                         ]
                     },
                     {
                         'ORG_NAME': '02数据二','label': '02数据二', 'ORG_NO': '02002','ORG_TYPE': '02', 'P_ORG_NO': '', children: [
                             {
                                 'ORG_NAME': '03数据二','label': '03数据二',  'ORG_NO': '03002','ORG_TYPE': '03', 'P_ORG_NO': '02002'
                             }
                         ]
                     }
                 ],
             }
        },
        created() {
            this.tickMenuIdFilter().filter(this.testOrgList1);
            console.log("data2", this.data2);
        },
        methods:{
          disFn(data,test){
              console.log(data,test,'55++++++++++')
              if(data.ORG_NO == this.orgno){
                return true
              }
          },
            handleChange(e,form,thsAreaCode){
                console.log(e)
                console.log(form)
                console.log(thsAreaCode)
            },
            handleNodeClick(data){
                console.log('看看', data);
            },
        }
    }
</script>
  • 使用props绑定一个对象通过条件判断来实现disabled的true和false来实现动态禁用状态