vue项目 实现倒计时结束后按钮可用

  • 开始时样式
    在这里插入图片描述
  • 倒计时结束后
    在这里插入图片描述
  • 直接上代码(涉及项目,所以此处只贴出了该部分的功能代码)
    <button class="brown" @click="close()">取消</button>
    <button class="default" v-show="show" @click="()=>{deleteFamily()}">确定</button>
    <button class="default" disabled="disabled" v-show="!show">确定({{count}}s)</button>

<script>
export default {
  data() { return { timer: null, count: null, show: true } },
  mounted() { this.getCode() },
  methods: {
    getCode() {
      let _this = this;
      _this.show = false;
      const TIME_COUNT = 5;
      if (!_this.timer) {
        _this.count = TIME_COUNT;
        _this.show = false;
        _this.timer = setInterval(() => {
          if (_this.count > 0 && _this.count <= TIME_COUNT) {
            _this.count--;
          } else {
            _this.show = true;
            clearInterval(_this.timer);
            _this.timer = null;
          }
        }, 1000)
      }
    }

  }
}
</script>

<style lang="scss">
  button {
    &.default {
      &:hover {
        background: rgba(239, 229, 222, 1);
      }

      &:disabled {
        opacity: 1 !important;
        padding: 6px 13px 5px 13px !important;
        color: rgba(173, 173, 173, 1);
        border: 1px solid rgba(207, 176, 155, 1);

        &:hover {
          background: #fff;
          cursor: not-allowed;
        }
      }
    }
}
</style>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值