方法一:

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();
}

方法一样式修改麻烦,但是代码简单

微信小程序弹出可填写框两种方法的更多相关文章

  1. 微信小程序--跳转页面常用的两种方法

    一.bindtap="onProductsItemTap"绑定点击跳转事件 在.wxml文件中绑定 在.js文件中实现绑定事件函数 二.navigator标签配合URL跳转法 在w ...

  2. 微信小程序弹出操作菜单

    微信小程序弹出操作菜单 比如在页面上放一个按钮,点击按钮弹出操作菜单,那么在按钮的 bindtap 事件里,执行下面的代码即可: wx.showActionSheet({ itemList: ['A' ...

  3. 微信小程序弹出层点击穿透问题

    问题描述:使用小程序的modal组件实现遮罩层效果时,会出现滚动穿透的问题,即遮罩层后面的页面依旧可以滚动. 解决方案: 给底层页面动态添加 position:fixed; 代码: wxml: < ...

  4. 微信小程序 - 弹出键盘遮挡住输入框

    在开发微信小程序的时候遇到,输入用户名或者手机号以及地址,手机键盘调起来,会把输入框遮挡. 如图: 以上两张图是自己工作中遇到的,此处不要着急,一个属性帮你搞定. cursor-spacing:指定光 ...

  5. 使用movable-view制作可拖拽的微信小程序弹出层效果。

    仿了潮汐睡眠小程序的代码.[如果有侵权联系删除 最近做的项目有个弹出层效果,类似音乐播放器那种.按照普通的做了一般感觉交互不是很优雅,设计妹子把潮汐睡眠的弹层给我看了看,感觉做的挺好,于是乘着有空仿照 ...

  6. 微信小程序弹出层

    1.消息提示     wx.showToast wx.showToast({ title: '成功', icon: 'success', duration: 2000 })2.模态弹窗 wx.show ...

  7. 微信小程序弹出框滚动穿透问题

    1.在你的遮罩层最外层加 catchtouchmove="noneEnoughPeople" 里面是你的方法名2.noneEnoughPeople: function () { c ...

  8. 微信小程序弹出层动画特效

    .rules_modal_cont{ height:800rpx; width:200rpx; -webkit-animation: showZeroAlert .3s; animation: sho ...

  9. 微信小程序弹出和隐藏遮罩层动画以及五星评分

    参考源码: http://www.see-source.com/weixinwidget/detail.html?wid=82 https://blog.csdn.net/pcaxb/article/ ...

随机推荐

  1. hdu 3415"Max Sum of Max-K-sub-sequence"(单调队列)

    传送门 题意: 给出一个有 N 个数字([-1000 , 1000],N ≤ 105)的环状序列: 让你求一个和最大的连续子序列,并记录起始点. 要求这个连续子序列的长度小于等于K,加和相同的不同区间 ...

  2. ideaJ+maven+javaweb实践: sevlet实现upload&download,javaIO代码

    因为工作的机器不让拷贝出来也不让发邮件出来也不让访问外网,所以文件两个PC挪来挪去很麻烦. 决定写一个网页,只有upload和download ideaJ,maven,java,tomcat 写一个j ...

  3. SSH框架下ajax调用action并生成JSON再传递到客户端【以get和post方式提交】

    需要完成的任务: 主要是把JSP页面上图片ID传给服务器端,服务器读取cookie看是否有username,如果有则根据ID读取MongoDB数据库,读出图片URL,再存放到mysql中的collec ...

  4. (选择不相交区间)今年暑假不AC hdu2037

    今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  5. Excel:6种多条件查找方法

    如下图所示,要求根据设备分类和品牌来查找相应的销售数量. 1. 使用VLOOKUP+辅助列进行多条件查找 本例采用的方法是在原表的最前面加一辅助列,辅助列的公式为:=B2&C2 然后再采用VL ...

  6. 10款 Mac 经典原型设计开发软件推荐

    在Mac上有大量强大的开发和设计工具,今天和大家推荐10款Mac上的经典原型设计开发工具,原型设计工具是开发者必备的一款工具,无论是网站开发还是移动APP开发,都需要在前期进行严格细致的原型设计,才能 ...

  7. Hbase学习04

    3.2.4 反向时间戳 反向扫描API HBASE-4811(https://issues.apache.org/jira/browse/HBASE-4811)实现了一个API来扫描一个表或范围内的一 ...

  8. HDFS-JavaAPI

    一.pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="h ...

  9. 【leetcode-82,83,26,80】 删除排序链表/数组中的重复元素

    83. 删除排序链表中的重复元素 (1 pass) 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次. 示例 1: 输入: 1->1->2 输出: 1->2 示例 2: ...

  10. Openresty 学习笔记(四)lualocks包管理器安装使用

    Luarocks是一个Lua包管理器,基于Lua语言开发,提供一个命令行的方式来管理Lua包依赖.安装第三方Lua包等,社区比较流行的包管理器之一,另还有一个LuaDist,Luarocks的包数量比 ...