您现在的位置是:网站首页> 编程资料编程资料
微信小程序原生自定义弹窗效果_javascript技巧_
2023-05-24
381人已围观
简介 微信小程序原生自定义弹窗效果_javascript技巧_
背景
微信小程序原生的在弹出层wx.showModal中可以通过配置项editable配置输入框,但是对于微信的版本有限制,微信版本过低无法显示,所以需要实现弹出层的效果
如下图

代码
index.wxml
请输入距离(km) 取消 确认
index.js
Page({ data: { inputDisValue:'', } }) //实时获取到输入的值 bindKeyInput(e) { console.log(e.detail.value) this.setData({ inputDisValue: e.detail.value }) }, hideCover(){ this.setData({ isShow: false }) }, showCover(){ this.setData({ isShow:true }) },index.wxss
.bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); padding: 0 20rpx; } .btn-group { position: absolute; left: 0; bottom: 0; width: 100%; display: flex; justify-content: space-around; font-weight: bold; padding: 20rpx 0; } .weui-input { background-color: #f1f1f1; border-radius: 10rpx; width: 400rpx; padding: 16rpx 16rpx; } .cover { width: 100%; height: 100%; position: fixed; top: 0; left: 0; display: flex; justify-content: center; align-items: center; z-index: 999; } .cover_child { width: 550rpx; height: 300rpx; background: rgba(255, 255, 255, 1); border-radius: 20rpx; display: flex; flex-direction: column; align-items: center; z-index: 5; } .child-title { white-space: nowrap; margin-top: 60rpx; height: 32rpx; font-size: 34rpx; font-weight: bold; color: #333333; line-height: 36rpx; margin-bottom: 31rpx; } .cross { margin-bottom: 110rpx; bottom: 0rpx; position: fixed; width: 60rpx; height: 60rpx; z-index: 5; }以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
您可能感兴趣的文章:
相关内容
- vue+elementUi实现点击地图自动填充经纬度以及地点_vue.js_
- Node.js数据流Stream之Readable流和Writable流用法_node.js_
- vue+elementui实现动态添加行/可编辑的table_vue.js_
- typescript+vite项目配置别名的方法实现_vue.js_
- Typescript中使用引用路径别名报错的解决方法_javascript技巧_
- typescript在node.js下使用别名(paths)无效的问题详解_javascript技巧_
- iview+vue实现导入EXCEL预览功能_vue.js_
- Node.js处理I/O数据之使用Buffer模块缓冲数据_node.js_
- vue实现页面添加水印_vue.js_
- vue中使用gantt-elastic实现可拖拽甘特图的示例代码_vue.js_
