微信小程序怎么实现弹出和隐藏遮罩层动画
发表于:2025-11-09 作者:千家信息网编辑
千家信息网最后更新 2025年11月09日,这篇文章主要介绍"微信小程序怎么实现弹出和隐藏遮罩层动画",在日常操作中,相信很多人在微信小程序怎么实现弹出和隐藏遮罩层动画问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答
千家信息网最后更新 2025年11月09日微信小程序怎么实现弹出和隐藏遮罩层动画
这篇文章主要介绍"微信小程序怎么实现弹出和隐藏遮罩层动画",在日常操作中,相信很多人在微信小程序怎么实现弹出和隐藏遮罩层动画问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"微信小程序怎么实现弹出和隐藏遮罩层动画"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

train.wxml
{{bankname}} {{index+1}}/{{allquestion.length}} {{questionlist.question}} A {{questionlist.choiceA}} B {{questionlist.choiceB}} C {{questionlist.choiceC}} D {{questionlist.choiceD}} 参考答案:{{questionlist.answer}}\n参考解析:{{questionlist.analysis}} 查看答案 这道题对你有用吗?评个分吧 确定
train.js
var interval = "";//周期执行函数的对象var time = 0;//滑动时间var touchDot = 0;//触摸时的原点var flag_hd = true;//判定是否可以滑动let animationShowHeight = 300;//动画偏移高度Page({ /** * 页面的初始数据 */ data: { // 遮罩层变量 animationData: "", showModalStatus: false, imageHeight: 0, imageWidth: 0, // 评分变量 stars: [0, 1, 2, 3, 4],//评分数值数组 normalSrc: '../images/score.png',//空心星星图片路径 selectedSrc: '../images/fullstar.png',//选中星星图片路径 key: 0,//评分 }, //点击星星 selectRight: function (e) { var key = e.currentTarget.dataset.key console.log("得" + key + "分") this.setData({ key: key }) }, // 确定评分 mark_click: function () { this.hideModal() }, // 显示遮罩层 showModal: function () { //创建一个动画实例animation。调用实例的方法来描述动画。 var animation = wx.createAnimation({ duration: 500, //动画持续时间500ms timingFunction: "ease",//动画以低速开始,然后加快,在结束前变慢 delay: 0 //动画延迟时间0ms }) this.animation = animation //调用动画操作方法后要调用 step() 来表示一组动画完成 animation.translateY(animationShowHeight).step()// 在Y轴向上偏移300 this.setData({ //通过动画实例的export方法导出动画数据传递给组件的animation属性。 animationData: animation.export(), showModalStatus: true //显示遮罩层 }) setTimeout(function () { animation.translateY(0).step() this.setData({ animationData: animation.export() }) }.bind(this), 1) }, // 隐藏遮罩层 hideModal: function () { var animation = wx.createAnimation({ duration: 500, timingFunction: "ease", delay: 0 }) this.animation = animation; animation.translateY(animationShowHeight).step() this.setData({ animationData: animation.export(), }) setTimeout(function () { animation.translateY(0).step() this.setData({ animationData: animation.export(), showModalStatus: false }) }.bind(this), 200) }, // 评分按钮 score_click: function () { }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { flag_hd = true; //重新进入页面之后,可以再次执行滑动切换页面代码 clearInterval(interval); // 清除setInterval time = 0; let that = this; wx.getSystemInfo({ success: function (res) { animationShowHeight = res.windowHeight; } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { },})train.wxss
page { background-color: #fff;}/* -----------------评分遮罩层----------------- *//* 分享按钮 */.share_btn::after { border: none;}/* 整个评分遮罩层 */.buydes-dialog-container { width: 100%; height: 300rpx; justify-content: space-between; background-color: #fff; position: fixed; bottom: 101rpx; /* z-index: 998; */ border-top: 1rpx solid #e8e8e8;}/* 评分遮罩层顶部 */.buydes-dialog-container-top { height: 100rpx; padding-top: 20rpx; display: flex; justify-content: center; flex-grow: 1; font-size: 32rpx; color: #737373;}/* 评分遮罩层底部 */.buydes-dialog-container-bottom { height: 150rpx; padding-top: 20rpx; background-color: #fff; display: flex; justify-content: center; flex-grow: 0;}/* 空心的星星图片 */.star-image { position: absolute; top: 100rpx; width: 60rpx; height: 60rpx; src: "../../images/score.png";}/* 触发评分点击的区域 */.item { position: absolute; top: 0rpx; width: 60rpx; height: 60rpx;}/* 确认评分按钮 */.mark_btn { width: 100%; height: 100rpx; background-color: #fff; color: #55c5ac; display: flex; justify-content: center; align-items: center; border-top: 1rpx solid #eaeaea; margin-top: 60rpx; margin-bottom: 150rpx; font-size: 32rpx;}/* 透明遮罩层(上) */.touming_top { width: 100%; height: 900rpx; opacity: 0; position: fixed; bottom: 402rpx; z-index: 998;}/* 透明遮罩层(下) */.touming { width: 100%; height: 101rpx; opacity: 0; position: fixed; bottom: 0rpx; z-index: 998;}到此,关于"微信小程序怎么实现弹出和隐藏遮罩层动画"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
动画
评分
页面
函数
周期
监听
周期函数
生命
程序
方法
星星
学习
图片
实例
按钮
时间
事件
变量
更多
用户
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
兰帕网络技术有限公司怎么样
网络安全周2021主题手抄报
北京新翼软件开发有限公司
电商 云服务器
如何避免这些网络安全问题
直播平台个性化软件开发支持
北京纳睿通软件开发公司
日本网络技术环境发展史
网络安全生物制药
湖北手机软件开发公司
mysql开源数据库源码
平台存储管理服务器配置清单
局信息网络安全等级保护制度
网络安全注意事项高中
网络安全常识十条防骗十个不要
徐玉玉 网络安全
北京数据库讲师
小薇解说明日之后的服务器
汽车服务网络技术论文
网络安全公益漫画
托马斯 阿芒 数据库
java 搜索 数据库
软件卸载如何恢复数据库
网络安全周宣传台词
黄岛区游戏软件开发公司
扫描枪条码上传数据库
海湾crt数据库
互联网络技术考试
数据库连接池初始化
杭州雷迅网络技术有限公司