微信小程序自定義彈出層效果
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)彈出層效果的具體代碼,供大家參考,具體內(nèi)容如下
效果圖

WXML
<view class='popup' wx:if="{{popShow}}">
<view class='mask' catchtouchmove="preventTouchMove" catchtap='closePop'>
</view>
<!-- 彈出層 -->
<view class='popup_main' id='popup_main' >
<!-- 關(guān)閉按鈕 -->
<view class='close_wrapper'>
<image class='close_icon' src='/images/select_icons/close.png' mode='widthFix' bindtap='closePop'></image>
</view>
<!-- 主要內(nèi)容 -->
<view class='pop_list_wrapper'>這里加入你想加入的內(nèi)容</view>
</view>
</view>
WXSS
.popup {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 9999;
}
.mask {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
}
.popup_main {
position: fixed;
top: 50%;
left: 50%;
width: 85%;
transform: translate(-50%, -50%);
padding: 10px;
box-sizing: border-box;
background-color: #fff;
border: 5px;
border-radius: 10px;
}
.close_wrapper {
width: 100%;
height: 20px;
display: flex;
align-items: center;
justify-content: flex-end;
}
.close_icon {
width: 16px;
}
JS
data: {
/** 彈出層 **/
popShow: false,
}
/**
* 彈出層
*/
// 打開彈窗
popupTap: function (e) {
this.setData({
popShow: true
})
},
// 關(guān)閉彈窗
closePop: function (e) {
this.setData({
popShow: false
})
},
// 這個(gè)函數(shù)內(nèi)容為空 用于阻止屏幕滾動
preventTouchMove: function (e) {
},
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS與SQL方式隨機(jī)生成高強(qiáng)度密碼示例
這篇文章主要介紹了JS與SQL方式隨機(jī)生成高強(qiáng)度密碼,結(jié)合實(shí)例形式分析了javascript方式與SQL方式生成高強(qiáng)度密碼的相關(guān)操作技巧,需要的朋友可以參考下2018-12-12
JS函數(shù)arguments數(shù)組獲得實(shí)際傳參數(shù)個(gè)數(shù)的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄狫S函數(shù)arguments數(shù)組獲得實(shí)際傳參數(shù)個(gè)數(shù)的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-05-05
利用js將ajax獲取到的后臺數(shù)據(jù)動態(tài)加載至網(wǎng)頁中的方法
今天小編就為大家分享一篇利用js將ajax獲取到的后臺數(shù)據(jù)動態(tài)加載至網(wǎng)頁中的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08
vite添加環(huán)境變量import.meta.env的方法
在不同的文件里面配置不同的環(huán)境變量,可以讓我們的配置更加容易維護(hù)和使用,這里我們說下vite配置環(huán)境變量和模式是怎么配置的,對vite環(huán)境變量相關(guān)知識感興趣的朋友跟隨小編一起看看吧2023-10-10

