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

<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>

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

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值