這篇文章主要講解了vue slot創(chuàng)建一個(gè)模態(tài)框的方法,內(nèi)容清晰明了,對(duì)此有興趣的小伙伴可以學(xué)習(xí)一下,相信大家閱讀完之后會(huì)有幫助。

成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括永吉網(wǎng)站建設(shè)、永吉網(wǎng)站制作、永吉網(wǎng)頁(yè)制作以及永吉網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,永吉網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到永吉省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
【1】遮罩層:承載內(nèi)容,管理樣式布局。
【2】?jī)?nèi)容層:控制遮罩層的顯示與否。
遮罩層和內(nèi)容區(qū)之間應(yīng)該解耦。遮罩層和內(nèi)容區(qū)之間應(yīng)該解耦。遮罩層和內(nèi)容區(qū)之間應(yīng)該解耦。
遮罩層不依賴于內(nèi)容區(qū),內(nèi)容是放置在遮罩層里的,至于內(nèi)容區(qū)里的內(nèi)容是什么,遮罩層完全不用在意。因此可以在遮罩層里采用插槽。
遮罩層的實(shí)現(xiàn)
<div class="common-mask" v-if="visible"> <slot name="head"></slot> <slot name="body"></slot> <slot name="foot"></slot> </div>
<style scoped lang='scss'>
.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;
}
</style>內(nèi)容層的實(shí)現(xiàn)
<Vue-Modal :visible="visible"> <div slot="head">head</div> <div slot="body">body</div> <div slot="foot"> <button class="common-btn" @click="close">Close</button> </div> </Vue-Modal>
PS:vue組件模態(tài)框?qū)崿F(xiàn)方式
// 組件代碼
<template>
<div>
<div class="dialog-modal"> <!-- 根元素,z-index 需要高于父容器其他元素 -->
<div class="dialog-wrapper" @click="onClose" v-show="isShow"></div> <!-- 加載一個(gè)具有透明度的背景,使根元素透明,子元素會(huì)繼承該透明度 -->
<transition name="drop">
<div class="dialog-container" v-show="isShow"> <!-- 模態(tài)框容器,z-index 需要高于背景 -->
<span class="close-btn" @click="onClose">x</span>
<slot>
<p>hello</p>
</slot>
</div>
</transition>
</div>
</div>
</template>
<script>
export default {
props: {
isShow:{
type: Boolean,
default: false
}
},
methods: {
onClose(){
this.$emit('on-close');
}
}
}
</script>
<style>
.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%;
/* margin: 0 auto; */
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;
}
</style>// 組件使用
//導(dǎo)入模態(tài)對(duì)話框
import modal from './plugins/dialog'
// 在使用組件
<modal></modal>
<modal @on-close="closeThis('isShowLog')":is-show='isShowLog'><login></login></modal>看完上述內(nèi)容,是不是對(duì)vue slot創(chuàng)建一個(gè)模態(tài)框的方法有進(jìn)一步的了解,如果還想學(xué)習(xí)更多內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
當(dāng)前文章:vueslot創(chuàng)建一個(gè)模態(tài)框的方法
文章URL:http://www.chinadenli.net/article36/pesspg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、營(yíng)銷型網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站維護(hù)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)