vue按钮禁用

一个按钮的动态禁用设置是如此多坑

必须要用到prop、data

prop来绑定其属性disabled,data是因为prop属性的内容不可改变。

<template>
  <div>
    <el-button type="success" size="small" @click="check">龟龟</el-button>
  <el-button type="success" size="small"  :disabled="flagBtn">查询</el-button>
  <!-- <el-button type="success" size="small" :disabled="btnDis"  @click="change">查询</el-button> -->
  </div>
</template>

<script>


export default {
  props: {
    disabled: {
      type:Boolean,
      default:true
    }
  },
  data() {
    return{
      flagBtn :this.disabled
    }
   
  },
  methods: {
    check(){
      // alert(this.disabled);
      // alert(this.flagBtn);
      this.flagBtn = false
      
    }
    
  }

  
};
</script>

<style>
</style>
posted @   Dinesaw  阅读(260)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

阅读目录(Content)

此页目录为空

点击右上角即可分享
微信分享提示