最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序自定義彈出模態(tài)框禁止底部滾動(dòng)功能

 更新時(shí)間:2020年03月09日 14:22:09   作者:面壁思過(guò)程  
這篇文章主要介紹了微信小程序自定義彈出模態(tài)框禁止底部滾動(dòng)效果,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

圖示:

wxml代碼:

<view class='fix_bottom'>
<view>分享</view>
<view>電話(huà)咨詢(xún)</view>
<view class='active' bindtap="showDialogBtn">立即報(bào)名</view>
</view>

<!--模態(tài)框-->
<!-- 遮罩層 -->
<view class="modal-mask" bindtap="hideModal" catchtouchmove="preventTouchMove" wx:if="{{showModal}}"></view>

<view class="modal-dialog" wx:if="{{showModal}}">
<view class="modal-title">選擇班次</view>
<view class="modal-content">
<view class="concent_list {{curindex==index? 'active':''}}" wx:for="{{concent_list}}" wx:for-index='index' data-index='{{index}}' bindtap='choose' data-name='{{item}}'>{{item}}</view>
</view>

<view class="modal-footer">
<view class="btn-cancel" bindtap="onCancel" data-status="cancel">取消</view>
<view class="btn-confirm" bindtap="onConfirm" data-status="confirm">確定</view>
</view>
</view>

wxss代碼

.fix_bottom{
width: 100%;
height: 120rpx;
background: #fff;
position: fixed;
bottom: 0;
border-top: 1px solid #ccc;
display: flex;
}

.fix_bottom view{
width: 33.333%;
border-left: 1px solid #ccc;
line-height: 120rpx;
text-align: center;
font-size: 40rpx;
font-weight: bold;
}

.active{
color:#ffffff;
background: -moz-linear-gradient(left, #ff7b68, #ff5462);
 /* Safari 4-5, Chrome 1-9 */
 /* -webkit-gradient(, [, ]?, [, ]? [, ]*) */
 background: -webkit-gradient(linear,left,from(#ff7b68),to(#ff5462));
 /* Safari 5.1+, Chrome 10+ */
 background: -webkit-linear-gradient(left, #ff7b68, #ff5462);
 /* Opera 11.10+ */
 background: -o-linear-gradient(left, #ff7b68, #ff5462);
}

/* 模態(tài)框 */

.modal-mask {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
opacity: 0.5;
overflow: hidden;
z-index: 9000;
color: #fff;
}

.modal-dialog {
width: 540rpx;
overflow: hidden;
position: fixed;
top: 40%;
left: 0;
z-index: 9999;
background: #f9f9f9;
margin: -180rpx 105rpx;
border-radius: 36rpx;
}

.modal-title {
height: 100rpx;
line-height: 100rpx;
font-size: 36rpx;
color: #fff;
text-align: center;
background: -moz-linear-gradient(left, #ff7b68, #ff5462);
 /* Safari 4-5, Chrome 1-9 */
 /* -webkit-gradient(, [, ]?, [, ]? [, ]*) */
 background: -webkit-gradient(linear,left,from(#ff7b68),to(#ff5462));
 /* Safari 5.1+, Chrome 10+ */
 background: -webkit-linear-gradient(left, #ff7b68, #ff5462);
 /* Opera 11.10+ */
 background: -o-linear-gradient(left, #ff7b68, #ff5462);
border-bottom: 1px solid #ccc;

}

.modal-content {

}

.concent_list{
width: 100%;
height: 100rpx;
border-bottom: 1px solid #ccc;
line-height: 100rpx;
text-align: center;
}

.modal-footer {
display: flex;
flex-direction: row;
height: 86rpx;
font-size: 34rpx;
line-height: 86rpx;
}

.btn-cancel {
width: 50%;
color: #666;
text-align: center;
border-right: 1px solid #dedede;
}

.btn-confirm {
width: 50%;
color: #ec5300;
text-align: center;
}

js代碼

var value='小學(xué)升初中'
Page({

/**
* 頁(yè)面的初始數(shù)據(jù)
*/
data: {
showModal: false,
concent_list:['小學(xué)升初中','初一升初二','初二升初三','初中升高中'],
curindex:-1
},

/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
*/
onLoad: function (options) {

},

/**
* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示
*/
onShow: function () {
},

/**
* 彈窗
*/
showDialogBtn: function () {
this.setData({
showModal: true
})
},

/**
* 隱藏模態(tài)對(duì)話(huà)框
*/
hideModal: function () {
this.setData({
showModal: false
});
},

/**
* 對(duì)話(huà)框取消按鈕點(diǎn)擊事件
*/
onCancel: function () {
this.hideModal();
},
/**
* 對(duì)話(huà)框確認(rèn)按鈕點(diǎn)擊事件
*/
onConfirm: function () {
this.hideModal();

})
},

choose:function(e){
var index=e.currentTarget.dataset.index
value = e.currentTarget.dataset.name
console.log(value)
this.setData({
curindex:index
})
}

})

模態(tài)框顯示時(shí)禁止底部?jī)?nèi)容滾動(dòng)可以在彈出時(shí)給底部包裹部分加上固定定位,模態(tài)框隱藏時(shí)取消固定定位

內(nèi)容包裹的元素需要設(shè)置100%的寬度

<view class='diceng_wrap' style='position: {{position}}'>
底部所有內(nèi)容內(nèi)容內(nèi)容
</view>

data數(shù)據(jù)的變化:

初始化時(shí):

 position: 'auto',

模態(tài)框顯示時(shí):

position: 'fixed',

模態(tài)框隱藏時(shí):

position: 'auto',

模態(tài)框顯示時(shí)

總結(jié)

到此這篇關(guān)于微信小程序自定義彈出模態(tài)框禁止底部滾動(dòng)功能的文章就介紹到這了,更多相關(guān)微信小程序彈出模態(tài)框內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

肃宁县| 民丰县| 扶余县| 阳城县| 南靖县| 古交市| 和龙市| 阳高县| 云林县| 大竹县| 洪湖市| 徐水县| 焉耆| 大安市| 镇巴县| 环江| 醴陵市| 云林县| 鄂尔多斯市| 九寨沟县| 大兴区| 缙云县| 翁源县| 夏邑县| 荥经县| 通城县| 宜阳县| 海阳市| 昆山市| 镶黄旗| 额济纳旗| 玉屏| 买车| 大化| 兴隆县| 平原县| 五寨县| 阿坝县| 讷河市| 宜川县| 理塘县|