栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

如何使用vue slot创建一个模态框的实例代码

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何使用vue slot创建一个模态框的实例代码

【1】遮罩层:承载内容,管理样式布局。

【2】内容层:控制遮罩层的显示与否。

遮罩层和内容区之间应该解耦。遮罩层和内容区之间应该解耦。遮罩层和内容区之间应该解耦。

遮罩层不依赖于内容区,内容是放置在遮罩层里的,至于内容区里的内容是什么,遮罩层完全不用在意。因此可以在遮罩层里采用插槽。

遮罩层的实现


 
 
 
 

 .common-mask {
 position: fixed;
 top: 0;
 bottom: 0;
 left: 0;
 right: 0;
 background: rgba($color: #000000, $alpha: 0.75);
 display: flex;
 justify-content: center;
 align-content: center;
 z-index: 4;
 }

内容层的实现


 head
 body
 
 
 
 

PS:vue组件模态框实现方式

// 组件代码




.drop-enter-active {
 transition: all .5s;
}
.drop-leave-active {
 transition: all .3s;
}
.drop-enter {
 transform: translateY(-500px);
}
.drop-leave-active {
 transform: translateY(-500px);
}  
 
  .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: #eee;
    opacity: .9;
  }
  .dialog-container{
    position: fixed;
    z-index:80;
    top: 10%;
    left: 25%;
    width: 50%;
    
    background-color: #eee;
    border-radius: 3px;
    box-shadow: 0 5px 15px rgba(0,0,0,.5);
  }
  span.close-btn{
    padding: 0 5px;
    float: right;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
  }

// 组件使用

//导入模态对话框
import modal from './plugins/dialog'
// 在使用组件


总结

到此这篇关于如何使用vue slot创建一个模态框的文章就介绍到这了,更多相关vue slot创建模态框内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/70238.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号