场景:当ajax请求回来的数据为空时,btn为disabled的状态,否则,btn的disabled属性为false

代码:

<button class="iconDivIcon targetBtn" :class="isdisabled?btndisabled:''"  style="width:100px;" @click="changeEnables(0)" :disabled="isdisabledFn">禁用</button>  

<div id="app"><button :disabled="isdisabledFn">测试</button><div>    

 

js中:

var app=new Vue({

        el:"#app",

        data:{

                isDisabl:true

        },

        computed:{

                isdisabledFn(){

                    if(后台传过来的数据!=null){

                            return this.isdisabled=false;

                    }else{

                            return this.isdisabled=true;

                    }

                }

        }

})

Logo

前往低代码交流专区

更多推荐