微信小程序弹出可填写框两种方法
方法一:
html页面: < view class = "container"
class = "zn-uploadimg" > < button type = "primary"
bindtap = "modalinput" > modal有输入框 < /button>
</view > < modal id = "modal"
hidden = "{{hiddenmodalput}}"
title = "预约信息"
confirm - text = "提交"
cancel - text = "取消"
bindcancel = "cancel"
bindconfirm = "confirm" > < input type = 'text'
placeholder = "姓名:"
auto - focus / > < input type = 'number'
placeholder = "电话:"
auto - focus / > < input type = 'text'
placeholder = "人数:"
auto - focus / > < input type = 'text'
placeholder = "时间:"
auto - focus / > < /modal>
js页面: / / 获取应用实例
var app = getApp()
Page({
data: {
hiddenmodalput: true,
//可以通过hidden是否掩藏弹出框的属性,来指定那个弹出框
},
//点击按钮痰喘指定的hiddenmodalput弹出框
modalinput: function() {
this.setData({
hiddenmodalput: !this.data.hiddenmodalput
})
},
//取消按钮
cancel: function() {
this.setData({
hiddenmodalput: true
});
},
//确认
confirm: function() {
this.setData({
hiddenmodalput: true
})
}
})
方法二:
html页面: < button class = "show-btn"
bindtap = "showDialogBtn" > 弹窗 < /button>
<!--弹窗-->
<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="modal-input">
<input placeholder-class="input-holder" type="number" maxlength="10" bindinput="inputChange" class="input" placeholder="姓名"></input > < /view>
<view class="modal-input">
<input placeholder-class="input-holder" type="number" maxlength="10" bindinput="inputChange" class="input" placeholder="电话"></input > < /view>
<view class="modal-input">
<input placeholder-class="input-holder" type="number" maxlength="10" bindinput="inputChange" class="input" placeholder="人数"></input > < /view>
<view class="modal-input">
<input placeholder-class="input-holder" type="number" maxlength="10" bindinput="inputChange" class="input" placeholder="时间"></input > < /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 > css页面:
/**index.wxss**/
.show - btn {
margin - top: 100rpx;
color: #22cc22;
}
.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: 50 % ;
left: 0;
z - index: 9999;
background: #fff;
margin: -180rpx 105rpx;
border - radius: 36rpx;
}.modal - title {
padding - top: 50rpx;
font - size: 36rpx;
color: #030303;
text-align: center;
}
.modal-content {
padding: 50rpx 32rpx;
}
.modal-input {
display: flex;
background: # fff;
border - bottom: 2rpx solid# ddd;
border - radius: 4rpx;
font - size: 28rpx;
}.input {
width: 100 % ;
height: 82rpx;
font - size: 28rpx;
line - height: 28rpx;
padding: 0 20rpx;
box - sizing: border - box;
color: #333;
}
input-holder {
color: # 666;
font - size: 28rpx;
}.modal - footer {
display: flex;
flex - direction: row;
height: 86rpx;
border - top: 1px solid# dedede;
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页面:
/**
* 弹窗
*/
showDialogBtn: function() {
this.setData({
showModal: true
})
},
/**
* 弹出框蒙层截断touchmove事件
*/
preventTouchMove: function() {},
/**
* 隐藏模态对话框
*/
hideModal: function() {
this.setData({
showModal: false
});
},
/**
* 对话框取消按钮点击事件
*/
onCancel: function() {
this.hideModal();
},
/**
* 对话框确认按钮点击事件
*/
onConfirm: function() {
wx.showToast({
title: '提交成功',
icon: 'success',
duration: 2000
})
this.hideModal();
}
方法一样式修改麻烦,但是代码简单
微信小程序弹出可填写框两种方法的更多相关文章
- 微信小程序--跳转页面常用的两种方法
一.bindtap="onProductsItemTap"绑定点击跳转事件 在.wxml文件中绑定 在.js文件中实现绑定事件函数 二.navigator标签配合URL跳转法 在w ...
- 微信小程序弹出操作菜单
微信小程序弹出操作菜单 比如在页面上放一个按钮,点击按钮弹出操作菜单,那么在按钮的 bindtap 事件里,执行下面的代码即可: wx.showActionSheet({ itemList: ['A' ...
- 微信小程序弹出层点击穿透问题
问题描述:使用小程序的modal组件实现遮罩层效果时,会出现滚动穿透的问题,即遮罩层后面的页面依旧可以滚动. 解决方案: 给底层页面动态添加 position:fixed; 代码: wxml: < ...
- 微信小程序 - 弹出键盘遮挡住输入框
在开发微信小程序的时候遇到,输入用户名或者手机号以及地址,手机键盘调起来,会把输入框遮挡. 如图: 以上两张图是自己工作中遇到的,此处不要着急,一个属性帮你搞定. cursor-spacing:指定光 ...
- 使用movable-view制作可拖拽的微信小程序弹出层效果。
仿了潮汐睡眠小程序的代码.[如果有侵权联系删除 最近做的项目有个弹出层效果,类似音乐播放器那种.按照普通的做了一般感觉交互不是很优雅,设计妹子把潮汐睡眠的弹层给我看了看,感觉做的挺好,于是乘着有空仿照 ...
- 微信小程序弹出层
1.消息提示 wx.showToast wx.showToast({ title: '成功', icon: 'success', duration: 2000 })2.模态弹窗 wx.show ...
- 微信小程序弹出框滚动穿透问题
1.在你的遮罩层最外层加 catchtouchmove="noneEnoughPeople" 里面是你的方法名2.noneEnoughPeople: function () { c ...
- 微信小程序弹出层动画特效
.rules_modal_cont{ height:800rpx; width:200rpx; -webkit-animation: showZeroAlert .3s; animation: sho ...
- 微信小程序弹出和隐藏遮罩层动画以及五星评分
参考源码: http://www.see-source.com/weixinwidget/detail.html?wid=82 https://blog.csdn.net/pcaxb/article/ ...
随机推荐
- (分治法 快速幂)51nod1046 A^B Mod C
1046 A^B Mod C 给出3个正整数A B C,求A^B Mod C. 例如,3 5 8,3^5 Mod 8 = 3. 收起 输入 3个正整数A B C,中间用空格分隔.(1 < ...
- Python入门介绍
Python入门介绍(人生苦短,我用 Python) Python简介 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹 ...
- db mysql / mysql cluster 5.7.19 / performance
s 问题1: 数据库底层若表碎片化严重,导致表索引走向偏差,致使该表读写速度变慢,影响业务运行 解决1: 数据库表重组 end
- Spring Boot笔记三:配置文件
配置文件这里需要讲的东西很多,所以我写在了这里,但是这个是和上篇文章衔接的,所以看这篇文章,先看上篇文章笔记二 一.单独的配置文件 配置文件里面不能都写我们的类的配置吧,这样那么多类太杂了,所以我们写 ...
- JAVA核心技术I---JAVA基础知识(static关键字)
一:static特殊关键字用处 –变量 –方法 –类 –匿名方法 二:静态变量:类共有成员 –static变量只依赖于类存在(通过类即可访问),不依赖于对象实例存在. –所有的对象实例,对于静态变量都 ...
- 2018牛客网暑期ACM多校训练营(第一场)B Symmetric Matrix(思维+数列递推)
题意 给出一个矩阵,矩阵每行的和必须为2,且是一个主对称矩阵.问你大小为n的这样的合法矩阵有多少个. 分析 作者:美食不可负064链接:https://www.nowcoder.com/discuss ...
- PHP7 学习笔记(十一)使用phpstudy快速配置一个虚拟主机
说明:为了windows本地开发php方便,这里推荐使用PHP集成环境phpstudy. 目的:使用域名访问项目(tinywan.test) 1.官网:http://www.phpstudy.net ...
- linux 中 如何 搜索 指定目录 下 指定文件 的 指定内容
开发时,经常遇到 全局查找某些代码 linux 中 如何 检索 某 目录下指定文件 的 指定内容如下: //.点为查找当前目录 下 的 所有 *.php 文件里 有 hello 的文件 find . ...
- Your accoutn already has a valid IOS Distribution certificate
这个问题是IOS证书不对,登录Apple开发中心,清空所有证书,然后再Archive->Reset.
- NFine框架全选checkBox列错位
在jqgrid.css里找到 .ui-jqgrid .cbox{margin-left: -1px;position: initial;vertical-align: text-bottom;}.ui ...