vue2实现模态框

作者: 自然python | 来源:发表于2017-11-06 16:37 被阅读0次

<template>
<div>
<div class="">
<button type="button" name="button" @click="offClose">模态框</button>
</div>

<div class="dialog-modal">

<div class="dialog-wrapper" @click="onClose" v-show="isShow"></div>

<transition name="drop">
  <div class="dialog-container" v-show="isShow">
 
    <div class="" style="width:100%;height:40px;border-radius:5px 5px 0px 0px;background:#fff">
      <span class="close-btn" @click="onClose">关闭</span>
    </div>
    <slot>
      <div class="" style="height:100%;width:100%;text-align:center">
        ![](./img/userimg/1.jpg)//换成你自已的图片地址
      </div>
    </slot>
  </div>
</transition>

</div>
</div>
</template>
<script>
export default {
data() {
return {
isShow: false
}
},
methods: {
offClose() {
this.isShow = !this.isShow;
},
onClose() {
this.isShow = false;
}
}

}
</script>
<style>
.dialog-modal {
position: absolute;
z-index: 5;
}

.dialog-wrapper {
position: fixed;
height: 100%;
width: 100%;
z-index: 5;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.dialog-wrapper {
background-color: #000;
opacity: .8;
}
.dialog-container {
position: fixed;
z-index: 80;
top: 20px;
left: 5%;
width: 90%;
height: 96%;
background-color: #eee;
border-radius: 5px;
box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
}
span.close-btn {
padding: 5px 10px;
float: right;
cursor: pointer;
font-size: 16px;
font-weight: bold;
}
</style>

12121.png

相关文章

  • 进阶任务10-事件应用

    实现Tab切换的功能 实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • vue2实现模态框

    export default {data() {retu...

  • 事件的应用

    1. 实现如下图Tab切换的功能 2. 实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • 进阶任务10

    1.实现如下图Tab切换的功能 2.实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • 事件的应用

    1.实现如下图Tab切换的功能: 2.实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • 事件的应用

    题目1: 实现如下图Tab切换的功能 地址 题目2:实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外...

  • 进阶任务10(主线任务):事件的应用

    题目1: 实现如下图Tab切换的功能 题目2:实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域...

  • 进阶10 事件的应用

    1: 实现如下图Tab切换的功能 完成效果 2. 实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的...

  • 进阶10作业

    题目1: 实现如下图Tab切换的功能Tabcode题目2:实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态...

  • 事件的应用

    Tab 效果的实现 模态框的实现

网友评论

    本文标题:vue2实现模态框

    本文链接:https://www.haomeiwen.com/subject/hrblmxtx.html