打开顶部弹窗搜索查看编辑修改首页UNITYNODEJSPYTHONAIGITPHPGOCEF3JAVAHTMLCSS搜索很楠不爱3 这个屌丝很懒,什么也没留下! 关注作者热门标签jqueryHTMLCSSPHPASPPYTHONGOAICC++C#PHOTOSHOPUNITYiOSandroidvuexml爬虫SEOLINUXWINDOWSJAVAMFCCEF3CADNODEJSGITPyppeteerarticle热门文章1PyQt设置右下角弹窗(转)_pyqt 写一个右下角2docker-compose.yml 语法说明_docker-compose working_dir 无效3SQL查询一(复习)_查询英语成绩信息(不显示重复值):数据库4vue项目关闭eslint方法_hbuilder x eslint-vue怎么关闭5HTML生日快乐代码 (粉色主题)(HTML5+CSS3+JS)520表白代码/七夕情人节网页/告白/求婚/生日快乐_生日快乐的链接代码6腾讯TRTC产品初体验(web)_腾讯云trtc 实时音视频个绍以及web本地搭建操作步骤7前端面试题72+_是一种网络页面设计布局,页面的设计与开发应当根据用户行为以及设备环境8五、Docker Compose下载安装及使用教程_docker-compose下载9新手上路之云服务器ESC centos系统配置jdk+tomcat+mysql_esc服务器安装tomcat java1.810django,postman工具的常见问题4.0_postman4.0当前位置: article > 正文 微信小程序弹窗 作者:很楠不爱3 | 2024-02-15 23:37:54 赞踩微信小程序弹窗 微信小程序自定义底部、顶部、中间、左边、右边弹窗 简单的微信小程序弹窗功能,具体实现过程,请浏览代码。 顶部弹出窗图例: 中间弹出窗图例: 底部弹出窗图例: 左边弹出窗图例: 右边弹出窗图例: wxml代码 <button type="primary" bindtap="openPopup" data-index="0">打开顶部弹窗</button> <button type="primary" bindtap="openPopup" data-index="1">打开中间弹窗</button> <button type="primary" bindtap="openPopup" data-index="2">打开底部弹窗</button> <button type="primary" bindtap="openPopup" data-index="3">打开左边弹窗</button> <button type="primary" bindtap="openPopup" data-index="4">打开右边弹窗</button> <!-- 顶部弹窗 --> <view class="popup-box" wx:if="{{showIndex=='0'}}" bindtap="closePopup"></view> <view class="info-top" wx:if="{{showIndex=='0'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,渚清沙白鸟飞回。</view> <view>无边落木萧萧下,不尽长江滚滚来。</view> <view>万里悲秋常作客,百年多病独登台。</view> <view>艰难苦恨繁霜鬓,潦倒新停浊酒杯。</view> </view> <view class="row-btn"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> <!-- 中间弹窗 --> <view class="popup-box" wx:if="{{showIndex=='1'}}" bindtap="closePopup"></view> <view class="info-center" style="top:{{height*0.3}}px;height:{{height*0.4}}px;" wx:if="{{showIndex=='1'}}"> <view> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,渚清沙白鸟飞回。</view> <view>无边落木萧萧下,不尽长江滚滚来。</view> <view>万里悲秋常作客,百年多病独登台。</view> <view>艰难苦恨繁霜鬓,潦倒新停浊酒杯。</view> </view> <view class="row-btn"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> </view> <!-- 底部弹窗 --> <view class="popup-box" wx:if="{{showIndex=='2'}}" bindtap="closePopup"></view> <view class="info-bottom" wx:if="{{showIndex=='2'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,渚清沙白鸟飞回。</view> <view>无边落木萧萧下,不尽长江滚滚来。</view> <view>万里悲秋常作客,百年多病独登台。</view> <view>艰难苦恨繁霜鬓,潦倒新停浊酒杯。</view> </view> <view class="row-btn"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> <!-- 左边弹窗 --> <view class="popup-box" wx:if="{{showIndex=='3'}}" bindtap="closePopup"></view> <view class="info-left" wx:if="{{showIndex=='3'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,</view> <view>渚清沙白鸟飞回。</view> <view>无边落木萧萧下,</view> <view>不尽长江滚滚来。</view> <view>万里悲秋常作客,</view> <view>百年多病独登台。</view> <view>艰难苦恨繁霜鬓,</view> <view>潦倒新停浊酒杯。</view> </view> <view class="row-btn fixed"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> <!-- 右边弹窗 --> <view class="popup-box" wx:if="{{showIndex=='4'}}" bindtap="closePopup"></view> <view class="info-right" wx:if="{{showIndex=='4'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,</view> <view>渚清沙白鸟飞回。</view> <view>无边落木萧萧下,</view> <view>不尽长江滚滚来。</view> <view>万里悲秋常作客,</view> <view>百年多病独登台。</view> <view>艰难苦恨繁霜鬓,</view> <view>潦倒新停浊酒杯。</view> </view> <view class="row-btn fixed"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 wxss代码 /* 蒙层 */ .popup-box{ position: absolute; z-index: 99; top: 0; background-color: rgba(0, 0, 0, 0.5); width: 100%; height: 100%; } /* 上 */ .info-top{ position: fixed; z-index: 999; width: 100%; top: 0; background-color: white; border-bottom-left-radius: 5rpx; border-bottom-right-radius: 5rpx; } /* 中 */ .info-center{ position: fixed; z-index: 999; background-color: white; display: flex; align-items: center; justify-content: center; border-radius: 10rpx; width: 90%; margin-left: 5%; margin-right: 5%; } /* 下 */ .info-bottom{ position: fixed; z-index: 999; width: 100%; bottom: 0; background-color: white; border-top-left-radius: 10rpx; border-top-right-radius: 10rpx; } /* 左 */ .info-left{ position: fixed; z-index: 999; width: 50%; height: 100%; top: 0; background-color: white; border-top-right-radius: 10rpx; border-bottom-right-radius: 10rpx; } /* 右 */ .info-right{ position: fixed; z-index: 999; width: 50%; height: 100%; right: 0; top: 0; background-color: white; border-top-left-radius: 10rpx; border-bottom-left-radius: 10rpx; } /* 自定义内容(根据自己需求更改,可删除) */ button{ margin: 15rpx 0; } .row-info{ display: flex; flex-direction: column; align-items: center; margin: 15rpx; font-size: 32rpx; } .row-info view{ padding: 10rpx 0; } .row-info view:first-child{ display: flex; flex-direction: row; align-items: center; } .line{ width: 100rpx; height: 1rpx; } .left-line{ background-image: linear-gradient(to left,orange,white); } .right-line{ background-image: linear-gradient(to right,orange,white); } .row-author{ font-size: 24rpx; color: gray; } .row-btn{ display: flex; flex-direction: row; align-items: center; border-top: 1rpx dashed #f1f1f1; } .row-btn view{ flex: 1; text-align: center; margin: 20rpx 10%; padding: 12rpx 0; font-size: 32rpx; border-radius: 10rpx; } .left-btn{ background-color: #f1f1f1; color: #33ccff; } .right-btn{ background-color: #33ccff; color: white; } .fixed{ position: fixed; bottom: 0; width: 50%; } 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 js代码 Page({ /** * 页面的初始数据 */ data: { showIndex:null,//打开弹窗的对应下标 height:'',//屏幕高度 }, // 打开弹窗 openPopup(e){ var index = e.currentTarget.dataset.index; this.setData({ showIndex:index }) }, //关闭弹窗 closePopup(){ this.setData({ showIndex:null }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { var that = this; // 动态获取屏幕高度 wx.getSystemInfo({ success: (result) => { that.setData({ height: result.windowHeight }); }, }) }, }) 123456789101112131415161718192021222324252627282930313233343536 代码简洁,类型齐全。本人才疏学浅,代码仅供参考,如有问题,请多多指教,酸Q。 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/88292推荐阅读articlemaven仓库的作用以及仓库的分类...maven的工作需要从仓库下载一些jar包,如下图所示,本地的项目A、项目B等都会通过maven软件从远程仓库(可以理解... 赞踩articleMaven配置远程仓库-详细操作_maven-source-plugin 部署 远程仓库...用maven管理项目时,需要通过pom添加jar,进行maven加载,有时候在公司你需要添加公司的私服maven仓库进行... 赞踩article开源啦!!!轻量级工作流引擎管理系统...控制面板对应的是右上角菜单缩小,可对画布进行缩小操作放大,可对画布进行放大操作适应,可对画布进行自适应操作上一步,可返回... 赞踩article微信小程序学习第9天——自定义组件的生命周期与组件所在页面的生命周期_组件生命周期声明对象,组件的生...微信小程序自定义组件的生命周期与组件所在页面的生命周期_组件生命周期声明对象,组件的生命周期 * :created、at... 赞踩articleGo Channel 面试题解析_go channel面试题...有一道这样的面试题目:写代码实现两个 goroutine,其中一个产生随机数并写入到 go channel 中,另外一个... 赞踩articleMysql数据库备份与恢复_mysql备份时 影响使用吗... 在mysql备份当中,我们一般有两种备份方法,一种叫逻辑备份mysqldump,另一种是物理备份xtrabackup... 赞踩article大数据采集与预处理技术...文章目录第1章 大数据概念1.1大数据的概念1.2大数据的关键技术1.3大数据采集与数据预处理技术第1章 大数据概念1.... 赞踩articleRuntimeError: CUDA error: device-side assert trigg...CUDA error_runtimeerror: cuda error: device-side assert trig... 赞踩articleMySQL--2--mysqldump参数详解...Mysqldump参数大全(参数来源于mysql5.5.19源码) 参数 参数说明 --all-databases , ... 赞踩articlecom.github.pagehelper.autoconfigure.PageHelperAuto...com.github.pagehelper.autoconfigure.PageHelperAutoConfigurat... 赞踩articleMySQL批量导出表结构...导出数据sql文件在命令窗口下, -d 后面跟着 test数据库名,test后面是需要导的表;db.sql 是导出的数据... 赞踩article【stomp实战】websocket原理解析与简单使用...WebSocket是HTML5提供的一种浏览器与服务器进行全双工通讯的网络技术,属于应用层协议。它基于TCP传输协议,并... 赞踩articlepython离线语音转文本,用Python实现不需要互联网的文本到语音转换?...根据documentation,尝试使用pyttsx3 2.5:gTTS which works perfectly i... 赞踩article【腾讯云 Cloud Studio 实战训练营】手把手带你使用通义千问AI能力+Cloud Stud...我们今天到底要干什么,大家应该已经知道了,没错就是实践一下官方“工资核算”的案例,通过对ai大模型的提问,得到我们想要的... 赞踩articlemaven详细配置教程-使用国内镜像-自定义仓库-环境变量配置-idea配置_maven国内镜像仓库...idea maven_maven国内镜像仓库maven国内镜像仓库 ... 赞踩article【Java EE初阶十一】文件操作(IO)...本篇内容主要讲解了io部分的知识点【Java EE初阶十一】文件操作(IO) 1. 认识文件 &... 赞踩article【MySQL】 MySQL的增删改查(进阶)--贰...数据库约束表的关系一对一:一对多:多对多:需要创建中间表来映射两张表的关系新增查询聚合函数:MAX、MIN、AVG、CO... 赞踩articlemaven坐标与仓库_mvnresponsity官网...1.坐标2.仓库本地仓库(在用户的.m2文件夹中)远程仓库:maven中有个默认pom.xml(所有项目的pom文件都继... 赞踩article华为机考入门python3--(12)牛客12-字符串反转...字符串是否为空 if not my_str。字符串逆序 my_str[::-1]by 软件工程小施同学。华为机考入门p... 赞踩article深度学习:目标分割|UNet网络模型及案例实现...1 UNet网络架构UNet网络由左编码部分,右解码部分和下两个卷积+激活层组成编码部分从图中可知:架构中是由4个重复结... 赞踩相关标签javamavenspring bootvue.jsjson数据库微信小程序学习小程序Mysql备份恢复数据挖掘big datahadoop操作系统网络springmysqlsqlwebsocket网络协议python离线语音转文本
赞
踩
微信小程序自定义底部、顶部、中间、左边、右边弹窗 简单的微信小程序弹窗功能,具体实现过程,请浏览代码。 顶部弹出窗图例: 中间弹出窗图例: 底部弹出窗图例: 左边弹出窗图例: 右边弹出窗图例:
<button type="primary" bindtap="openPopup" data-index="0">打开顶部弹窗</button> <button type="primary" bindtap="openPopup" data-index="1">打开中间弹窗</button> <button type="primary" bindtap="openPopup" data-index="2">打开底部弹窗</button> <button type="primary" bindtap="openPopup" data-index="3">打开左边弹窗</button> <button type="primary" bindtap="openPopup" data-index="4">打开右边弹窗</button> <!-- 顶部弹窗 --> <view class="popup-box" wx:if="{{showIndex=='0'}}" bindtap="closePopup"></view> <view class="info-top" wx:if="{{showIndex=='0'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,渚清沙白鸟飞回。</view> <view>无边落木萧萧下,不尽长江滚滚来。</view> <view>万里悲秋常作客,百年多病独登台。</view> <view>艰难苦恨繁霜鬓,潦倒新停浊酒杯。</view> </view> <view class="row-btn"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> <!-- 中间弹窗 --> <view class="popup-box" wx:if="{{showIndex=='1'}}" bindtap="closePopup"></view> <view class="info-center" style="top:{{height*0.3}}px;height:{{height*0.4}}px;" wx:if="{{showIndex=='1'}}"> <view> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,渚清沙白鸟飞回。</view> <view>无边落木萧萧下,不尽长江滚滚来。</view> <view>万里悲秋常作客,百年多病独登台。</view> <view>艰难苦恨繁霜鬓,潦倒新停浊酒杯。</view> </view> <view class="row-btn"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> </view> <!-- 底部弹窗 --> <view class="popup-box" wx:if="{{showIndex=='2'}}" bindtap="closePopup"></view> <view class="info-bottom" wx:if="{{showIndex=='2'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,渚清沙白鸟飞回。</view> <view>无边落木萧萧下,不尽长江滚滚来。</view> <view>万里悲秋常作客,百年多病独登台。</view> <view>艰难苦恨繁霜鬓,潦倒新停浊酒杯。</view> </view> <view class="row-btn"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> <!-- 左边弹窗 --> <view class="popup-box" wx:if="{{showIndex=='3'}}" bindtap="closePopup"></view> <view class="info-left" wx:if="{{showIndex=='3'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,</view> <view>渚清沙白鸟飞回。</view> <view>无边落木萧萧下,</view> <view>不尽长江滚滚来。</view> <view>万里悲秋常作客,</view> <view>百年多病独登台。</view> <view>艰难苦恨繁霜鬓,</view> <view>潦倒新停浊酒杯。</view> </view> <view class="row-btn fixed"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view> <!-- 右边弹窗 --> <view class="popup-box" wx:if="{{showIndex=='4'}}" bindtap="closePopup"></view> <view class="info-right" wx:if="{{showIndex=='4'}}"> <view class="row-info"> <view> <text class="line left-line"></text> <text>《登高》</text> <text class="line right-line"></text> </view> <view class="row-author">杜甫 〔唐代〕</view> <view>风急天高猿啸哀,</view> <view>渚清沙白鸟飞回。</view> <view>无边落木萧萧下,</view> <view>不尽长江滚滚来。</view> <view>万里悲秋常作客,</view> <view>百年多病独登台。</view> <view>艰难苦恨繁霜鬓,</view> <view>潦倒新停浊酒杯。</view> </view> <view class="row-btn fixed"> <view class="left-btn" bindtap="closePopup">取消</view> <view class="right-btn">确认</view> </view> </view>
/* 蒙层 */ .popup-box{ position: absolute; z-index: 99; top: 0; background-color: rgba(0, 0, 0, 0.5); width: 100%; height: 100%; } /* 上 */ .info-top{ position: fixed; z-index: 999; width: 100%; top: 0; background-color: white; border-bottom-left-radius: 5rpx; border-bottom-right-radius: 5rpx; } /* 中 */ .info-center{ position: fixed; z-index: 999; background-color: white; display: flex; align-items: center; justify-content: center; border-radius: 10rpx; width: 90%; margin-left: 5%; margin-right: 5%; } /* 下 */ .info-bottom{ position: fixed; z-index: 999; width: 100%; bottom: 0; background-color: white; border-top-left-radius: 10rpx; border-top-right-radius: 10rpx; } /* 左 */ .info-left{ position: fixed; z-index: 999; width: 50%; height: 100%; top: 0; background-color: white; border-top-right-radius: 10rpx; border-bottom-right-radius: 10rpx; } /* 右 */ .info-right{ position: fixed; z-index: 999; width: 50%; height: 100%; right: 0; top: 0; background-color: white; border-top-left-radius: 10rpx; border-bottom-left-radius: 10rpx; } /* 自定义内容(根据自己需求更改,可删除) */ button{ margin: 15rpx 0; } .row-info{ display: flex; flex-direction: column; align-items: center; margin: 15rpx; font-size: 32rpx; } .row-info view{ padding: 10rpx 0; } .row-info view:first-child{ display: flex; flex-direction: row; align-items: center; } .line{ width: 100rpx; height: 1rpx; } .left-line{ background-image: linear-gradient(to left,orange,white); } .right-line{ background-image: linear-gradient(to right,orange,white); } .row-author{ font-size: 24rpx; color: gray; } .row-btn{ display: flex; flex-direction: row; align-items: center; border-top: 1rpx dashed #f1f1f1; } .row-btn view{ flex: 1; text-align: center; margin: 20rpx 10%; padding: 12rpx 0; font-size: 32rpx; border-radius: 10rpx; } .left-btn{ background-color: #f1f1f1; color: #33ccff; } .right-btn{ background-color: #33ccff; color: white; } .fixed{ position: fixed; bottom: 0; width: 50%; }
Page({ /** * 页面的初始数据 */ data: { showIndex:null,//打开弹窗的对应下标 height:'',//屏幕高度 }, // 打开弹窗 openPopup(e){ var index = e.currentTarget.dataset.index; this.setData({ showIndex:index }) }, //关闭弹窗 closePopup(){ this.setData({ showIndex:null }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { var that = this; // 动态获取屏幕高度 wx.getSystemInfo({ success: (result) => { that.setData({ height: result.windowHeight }); }, }) }, })
代码简洁,类型齐全。本人才疏学浅,代码仅供参考,如有问题,请多多指教,酸Q。