vue中动态控制btn的disabled属性
场景:当ajax请求回来的数据为空时,btn为disabled的状态,否则,btn的disabled属性为false代码:<button class="iconDivIcon targetBtn" :class="isdisabled?btndisabled:''" style="width:100px;" @click="changeEnables(0)" :disable...
场景:当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;
}
}
}
})
更多推荐
所有评论(0)