vue 提示弹框

分享一个很好用的提示弹框(几秒消失的那种)

非常适用于前端内容增删改查成功或失败后的提示语

templet 中的 Dom


<div class="alsrtInfo" :style="{display: displayStsates}" ref="alertMsg">
    <div class="profPrompt_test">{{aletMsg}}</div>
</div>

 script 中的 data 和 methods


// data 中 增加
     aletMsg: '', // 弹出框中的提示语
     displayStsates: 'none'
// methods 中
    // 提示弹框
    alertDia (msg) {
      this.displayStsates = 'block'
      this.aletMsg = msg
      // 延迟2秒后消失 自己可以更改时间
      window.setTimeout(() => {
        this.displayStsates = 'none'
      }, 2000)
    },
// 直接调用,会弹出两秒自动关闭
    this.alertDia(aletMsg)

 css 中的样式 ,可以根据项目风格做适当修改 ,用的 scss 格式


  .alsrtInfo{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.1);
    .profPrompt_test{
      padding: 30px 10px;
      width: 480px;
      overflow: hidden;
      line-height: 28px;
      border: 1px solid #4eb6d3;
      color: #4eb6d3;
      position: absolute;
      background-color: #fbfbfb;
      top: 356px;
      left: 50%;
      font-size: 14px;
      font-family: Gotham-Book;
      opacity: 1;
      /* z-index: 1; */
      text-align: center;
      transform: translate(-50%, -50%);
    }
  }

 

  • 5
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值