手写全屏加载遮罩

<!-- 全屏加载遮罩 -->
<button @click="onSubmit">点击</button>
<div v-if="isLoading" class="fullscreen-mask">
    <div class="loading-content">
        <div class="small-spinner"></div>
        <p class="loading-text">加载中,请稍候...</p>
    </div>
</div>

data() {
    return {
        isLoading: false,
    }
}
methods:{
    onSubmit(){
        // 开始请求前显示加载动画
        this.isLoading = true;
        this.$post('app').then((res) => {
          let { msg, success } = res.data
          if (!success) {
            this.$message.error(msg);
            return
          }
          if (success) {
          // 无论成功或失败,请求完成后隐藏加载动画
          this.isLoading = false;

          }
          this.$message.success('关闭成功');
        })
    }
}
                            
<style scoped>
/* 全屏遮罩层 */
.fullscreen-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色遮罩 */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* 确保在最上层 */
}

/* 加载内容容器 */
.loading-content {
  text-align: center;
}

/* 小型转圈图标 */
.small-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s linear infinite;
}

/* 加载文字 */
.loading-text {
  color: white;
  margin-top: 16px;
  font-size: 16px;
}

/* 旋转动画 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
</style>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值