小程序、App自定义弹框(结合Tailwindcss或者unocss)

效果:

二次确认清除数据二次确认弹框xiang相关代码:

HTML代码:
 <view class="modal-container relative" v-if="showModal">
      <view class="absolute">
        <view class="flex justify-center h-562rpx">
          <image
            class="w-190rpx h-190rpx mb-20rpx"
            src="@/static/home/prompt.png"
            mode="aspectFill"
          ></image>
        </view>
      </view>
      <view class="modal">
        <view class="modal-content">
          <view class="text-#FF7171 text-40rpx font-600">温馨提示</view>
          <view class="text-#333 text-44rpx font-600 mt-30rpx mb-15rpx">
            您是否确定清空当前数据!
          </view>
          <view class="flex justify-around">
            <view class="btn2 btn-cancel" @click="handleCancel">
              <text class="text-#333 ml-12rpx text-32rpx">取消</text>
            </view>
            <view class="btn2 btn-confirm" @click="handleConfirm">
              <text class="text-#fff ml-12rpx text-32rpx">确认</text>
            </view>
          </view>
        </view>
      </view>
    </view>
script代码:
//控制弹框显示隐藏
const showModal = ref(false)


//触发弹框打开
const handlonNavRightClick = async () => {
  showModal.value = true
}

//弹框中确认操作
const handleConfirm = async () => {
  const res = await youAPI()
  if (res.code === 200) {
    //清除数据成功,关闭弹框
    showModal.value = false
    // 更新页面
    searchData()
  } else {
    //清除数据失败,给出提示
    uni.showToast({
      title: '参数错误',
      icon: 'none',
    })
    showModal.value = false
  }
}
// 弹框中取消操作
const handleCancel = () => {
  showModal.value = false
}
css代码:
  .btn2 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 272rpx;
    height: 60rpx;
    margin: 14rpx 0;
    border-radius: 12rpx;
  }
  .btn-cancel {
    height: 88rpx;
    background-color: rgba(241, 241, 241, 1);
    border-radius: 50rpx;
  }

  .btn-confirm {
    height: 88rpx;
    background-color: rgba(50, 118, 255, 1);
    border-radius: 50rpx;
  }
// 自定义弹框样式
.modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
}
.modal {
  background-color: white;
  padding: 80rpx 40rpx 40rpx 40rpx;
  width: 80%;
  border-radius: 10px;
  text-align: center;
}
.modal-image {
  width: 190rpx;
  height: 190rpx;
  margin-bottom: 10px;
}
.modal-content {
  margin-top: 10px;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值