vue中如何实现弹框dialog

这篇文章主要为大家展示了“vue中如何实现弹框dialog”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“vue中如何实现弹框dialog”这篇文章吧。

成都创新互联是一家专业提供蕉岭企业网站建设,专注与网站设计制作、成都网站制作、H5高端网站建设、小程序制作等业务。10年已为蕉岭众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。

效果如下,dialog中内容自行添加

vue中如何实现弹框dialog

<template>
 <div>
 <div class="dialog-wrap">
  <div class="dialog-cover" v-if="isShow" @click="closeMyself"></div>
  <transition name="drop">
  <div class="dialog-content" v-if="isShow">
   <p class="dialog-close" @click="closeMyself">x</p>
   <slot>empty</slot>
  </div>
  </transition>
 </div>
 </div>
</template>

接收父组件传参isShow,并返回一个自定义事件on-close

<script>
 export default {
 props: {
  isShow: {
  type: Boolean,
  default: false
  }
 },
 data () {
  return {
  }
 },
 methods: {
  closeMyself () {
  this.$emit('on-close')
  }
 }
 }
</script>
<style scoped>
 .drop-enter-active {
 transition: all .5s ease;
 }
 .drop-leave-active {
 transition: all .3s ease;
 }
 .drop-enter {
 transform: translateY(-500px);
 }
 .drop-leave-active {
 transform: translateY(-500px);
 }
 .dialog-wrap {
 position: fixed;
 width: 100%;
 height: 100%;
 }
 .dialog-cover {
 background: #000;
 opacity: .3;
 position: fixed;
 z-index: 5;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
 }
 .dialog-content {
 width: 50%;
 position: fixed;
 max-height: 50%;
 overflow: auto;
 background: #fff;
 top: 20%;
 left: 50%;
 margin-left: -25%;
 z-index: 10;
 border: 2px solid #464068;
 padding: 2%;
 line-height: 1.6;
 }
 .dialog-close {
 position: absolute;
 right: 5px;
 top: 5px;
 width: 20px;
 height: 20px;
 text-align: center;
 cursor: pointer;
 }
 .dialog-close:hover {
 color: #4fc08d;
 }
</style>

以上是“vue中如何实现弹框dialog”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!

本文名称:vue中如何实现弹框dialog
本文URL:https://www.cdcxhl.com/article42/ijggec.html

成都网站建设公司_创新互联,为您提供动态网站做网站网站维护网站营销网站制作用户体验

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设公司