uni-app封装二次确认按钮cus-comfirm-button

<template>
  <view class="box" :style="{ width: isConfirming ? comfirmWidth : '152rpx' }">
    <template v-if="isConfirming">
      <text>{{ comfirmTip }}</text>
      <view class="yes-no" @click="isConfirming = false">取消</view>
      <view class="yes-no" @click="comfirm">确定</view>
    </template>
    <view v-else class="btn" @click="isConfirming = true">{{ cancelText }}</view>
  </view>
</template>

<script>
export default {
  name: 'comfirmButton',
  props: {
    cancelText: {
      type: String,
      default: '取消加载'
    },
    comfirmTip: {
      type: String,
      default: '确定取消加载?'
    },
    comfirmWidth: {
      type: String,
      default: '560rpx'
    }
  },
  data () {
    return {
      isConfirming: false,
    }
  },
  methods: {
    comfirm () {
      this.isConfirming = false
      this.$emit('comfirm')
    }
  }
}
</script>

<style lang="scss" scoped>
.box {
  transition: width 0.5s ease-in-out;
  height: 64rpx;
  line-height: 64rpx;
  text-align: right;
  font-size: 28rpx;
  color: #0081ff;
  border: 1rpx solid #0081ff;
  border-radius: 36rpx;
  overflow: hidden;
  white-space: nowrap;

  text {
    vertical-align: top;
    margin-left: 10rpx;
  }

  .btn {
    width: 152rpx;
    height: 64rpx;
    line-height: 64rpx;
    text-align: center;
  }
}

.yes-no {
  text-align: center;
  display: inline-block;
  width: 152rpx;
  height: 50rpx;
  line-height: 46rpx;
  color: #fff;
  border: 1rpx solid #0081ff;
  background-color: #0081ff;
  margin: 6rpx 6rpx 6rpx 10rpx;
  border-radius: 25rpx;
}
</style>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值