微信小程序底部弹窗如何实现,代码是什么
Admin 2022-08-12 群英技术资讯 891 次浏览
这篇文章主要讲解了“微信小程序底部弹窗如何实现,代码是什么”,文中的讲解内容简单、清晰、详细,对大家学习或是工作可能会有一定的帮助,希望大家阅读完这篇文章能有所收获。下面就请大家跟着小编的思路一起来学习一下吧。本文实例为大家分享了微信小程序实现底部弹窗的具体代码,供大家参考,具体内容如下

xml:
<view bindtap="clickme">点击我可以看到底部弹框的出现</view>
<!--屏幕背景变暗的背景 -->
<view class="commodity_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view>
<!--弹出框 -->
<view animation="{{animationData}}" class="commodity_attr_box" wx:if="{{showModalStatus}}">
<!--自定义弹窗内容-->
</view>
css:
/*使屏幕变暗 */
.commodity_screen {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
opacity: 0.2;
overflow: hidden;
z-index: 1000;
color: #fff;
}
/*对话框 */
.commodity_attr_box {
height: 50%;
width: 100%;
overflow: hidden;
position: fixed;
bottom: 0;
left: 0;
z-index: 2000;
background: #fff;
padding-top: 20rpx;
}
js:
//点击我显示底部弹出框
clickme: function () {
this.showModal();
},
//显示对话框
showModal: function () {
// 显示遮罩层
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
showModalStatus: true
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export()
})
}.bind(this), 200)
},
//隐藏对话框
hideModal: function () {
// 隐藏遮罩层
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export(),
showModalStatus: false
})
}.bind(this), 200)
},
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
jquery选定元素修改属性的方法:1、利用“$(指定元素)”语句获取指定元素对象;2、利用attr()方法来修改已获取到元素对象的属性 ,语法为“元素对象.attr(attribute,value)”。
newArray(arg1,arg2,…),当参数长度为0或大于等于2时,传入的参数将依次成为新数组的第0至第N项。newArray(len),当len不是数值时,返回一个只包含len元素的数组。
delete属性是在JavaScript中经常使用的删除对象的一个属性,但是对于新手用户们来说却不是很了解其使用方法,那么接下来我们就一起去看看如何使用JavaScript delete属性的吧。
这篇文章主要介绍了如何理解JavaScript中的运算符,帮助大家更好的学习JavaScript,感兴趣的朋友可以了解下
这篇文章给大家分享的是React请求远程数据的相关内容,React中请求远程数据的方式有四种,具体怎样实现呢?文中的示例代码介绍得很详细,有需要的朋友可以参考,接下来就跟随小编一起了解看看吧。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008