vue自定义弹出层、vue自定义弹出框、vue上下左右居中弹出框

可直接拿去用,如果需要两个按钮,需自己手动添加

css

复制代码
/* 弹窗样式 */
.login {
  position: fixed;
  height: 100px;
  width: 240px;
  background: #ffffff;
  border-radius: 0.25rem;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}
.over {
  position: fixed;
  width: 100%;
  height: 100%;
  opacity: 0.2;
  filter: alpha(opacity=20);
  top: 0;
  left: 0;
  z-index: 999;
  background-color: #111111;
}
.popup_content{
    width: 90%;
    margin: auto;
    text-align: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin-top: -10px;
}
.close_popup_btn{
    width: 100%;
    height: 30px;
    line-height: 30px;
    text-align: center;
    position: absolute;
    left: 0;
    bottom: 0;
    border-top: 1px solid #eee;
}
复制代码

 

html

复制代码
<button @click="ShowPopup" style="width: 2rem;height: 0.6rem;line-height: 0.6rem;text-align: center;background: chartreuse;">自定义弹窗</button>
<div v-show="is_popup">
        <!--这里是要展示的内容层-->
        <div class="login">
            <p class="popup_content">这是提示内容</p>
            <div class="close_popup_btn" @click="close_popup_btn">确定</div>
        </div>
        <!--这里是半透明背景层-->
        <div class="over"></div>
</div>
复制代码

js

复制代码
data() {
        return {
             is_popup:false,
        }
},
methods: {
         ShowPopup(){
              this.is_popup=true
         },
         close_popup_btn(){
              this.is_popup=false
         },
},
复制代码

效果图

 

posted @   eternityQSL  阅读(1508)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了

喜欢请打赏

扫描二维码打赏

支付宝打赏

点击右上角即可分享
微信分享提示