利用 Vue 内联样式的绑定方法,实现按钮的显示与隐藏

导读:本篇文章讲解 利用 Vue 内联样式的绑定方法,实现按钮的显示与隐藏,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

<template>
<div>

  <div class="titles">
    <div style="display: flex;">

      <div class="btn-box-content">
        <div class="btn-status">
          <el-radio-group v-model="workFlowStatus" class="btn" @change="changeStatus">
            <el-radio-button label="todo">未毕业</el-radio-button>
            <el-radio-button label="done">已毕业</el-radio-button>
            <el-radio-button label="">全部</el-radio-button>
          </el-radio-group>
        </div>
      </div>

    </div>


  </div>

  <div style="display: flex; align-items: center;">
    <div style="display: flex; margin-left: 15px;" >
      <el-button type="default" size="middle" @click="unApply()" :style="{ display: active1 }">解除学籍</el-button>
      <el-button type="default" size="middle" @click="Apply()" :style="{ display: active2 }">恢复学籍</el-button>
    </div>
  </div>

</div>

</template>

<script>
  export default {
    data () {
      return {
        workFlowStatus: 'todo',
        active1: '',
        active2: 'none'
      }
    },
    methods: {
      // 根据状态隐藏按钮
      changeStatus () {
        if (this.workFlowStatus === 'todo') {
          this.active1 = ''
          this.active2 = 'none'
        } else if (this.workFlowStatus === 'done') {
          this.active1 = 'none'
          this.active2 = ''
        } else {
          this.active1 = 'none'
          this.active2 = 'none'
        }
      }
    }
  }
</script>

<style scope>

  .titles {
    display: flex;
    padding-bottom: 6px;
    clear: both;
    font-size: 11px;
    background-color: rgb(236, 246, 253);
    border: 1px solid rgb(210, 234, 251);
    justify-content: space-between;
    padding: 14px;
    border-radius: 5px;
    margin-top: 15px;
    margin-bottom: 10px;
  }
  .footer{
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #d9d9d9;
    width: 100%;
  }
  
</style>

效果如下图所示,点击未毕业时出现解除学籍按钮,点击已毕业时出现恢复学籍按钮,点击全部时,隐藏所有按钮

利用 Vue 内联样式的绑定方法,实现按钮的显示与隐藏

利用 Vue 内联样式的绑定方法,实现按钮的显示与隐藏

利用 Vue 内联样式的绑定方法,实现按钮的显示与隐藏

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/66447.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!