微信小程序新手教程表单的创建,本篇默认已经成功安装微信小程序工具,来和小编一起看看吧
数据请求 表单的创建 提交 与接收
开始正题了,本节小小研究了下 微信 小程序的表单创建与提交
1. 表单页面
{{notice_str}}
确认提交么?
2. js 代码
var app = getApp();
Page({
data:{
// text:"这是一个页面"
array:["中国","美国","巴西","日本"],
toast1Hidden:true,
modalHidden: true,
modalHidden2: true,
notice_str: '',
index:0
},
toast1Change:function(e){
this.setData({toast1Hidden:true});
},
//弹出确认框
modalTap: function(e) {
this.setData({
modalHidden: false
})
},
confirm_one: function(e) {
console.log(e);
this.setData({
modalHidden: true,
toast1Hidden:false,
notice_str: '提交成功'
});
},
cancel_one: function(e) {
console.log(e);
this.setData({
modalHidden: true,
toast1Hidden:false,
notice_str: '取消成功'
});
},
//弹出提示框
modalTap2: function(e) {
this.setData({
modalHidden2: false
})
},
modalChange2: function(e) {
this.setData({
modalHidden2: true
})
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
index: e.detail.value
})
},
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
},
onReady:function(){
// 页面渲染完成
},
onShow:function(){
// 页面显示
},
onHide:function(){
// 页面隐藏
},
onUnload:function(){
// 页面关闭
},
formSubmit: function(e) {
var that = this;
var formData = e.detail.value;
wx.request({
url: 'http://test.com:8080/test/socket.php?msg=2',
data: formData,
header: {
'Content-Type': 'application/json'
},
success: function(res) {
console.log(res.data)
that.modalTap();
}
})
},
formReset: function() {
console.log('form发生了reset事件');
this.modalTap2();
}
})
3. 部分样式
#adduser{
background: #f5f5f5;
}
.section__title{
float: left;
width:30%;
}
.form-group{
float: right;
width: 70%;
}
.section{
clear: both;
width:90%;
margin: 2rem auto;
}
.input-text{
border: 1px solid #ddd;
}
.button{
border: 1px solid #1aad19;
border-radius: 2px;
}
.picker{
padding: 13px;
background-color: #FFFFFF;
}
4. 服务器端
<!--?php
var_dump($_REQUEST);
本节 集合了
表单 https://mp.weixin.qq.com/debug/wxadoc/dev/component/form.html?t=1476197486816
数据请求 https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html?t=1476197484427
提示框 https://mp.weixin.qq.com/debug/wxadoc/dev/component/toast.html?t=1476197486420
确认和非确认框 https://mp.weixin.qq.com/debug/wxadoc/dev/component/modal.html?t=1476197489278
最近更新
淘宝微信支付怎么开通?9月5日淘宝公示与微信
人气排行
腾讯自QQ5.x开始便不再沿用年份命名,比如QQ2014、QQ2015,而是改
微信小视频保存在手机哪个文件。很多人都在玩微信的小视频这个功
QQ聊天中图片一直显示在缓冲显示不出来解决办法。很多人都会遇到
微信电脑版相比手机端聊天更加方便与快捷了,但是有的网友电脑因
QQ6.1版本之后,QQ群视频不仅改名为QQ群通话,而且还改成了普通用
微信头像对图片的尺寸大小并没有限制,但尺寸太小(分辨率/像素过
QQ超级会员8级,即SVIP8经过一段时间的内测后已经正式发布了。qq
微信是我们常用的软件,但是在使用过程中,有可能碰到删错了人或
手机QQ群匿名聊天功能怎么用qq群匿名聊天开启及关闭使用教程。手
手机QQ聊天、接收照片的时候选择了保存到手机,但是还是不知道保