小程序form表单提交
最近在开发一个小程序,里面有一个form表单的提交,是textarea和input组合使用的,第一行是textarea,其余的都是input,自上而下输入,点击提交,在开发者工具上没问题,可以跳转页面,在真机上就不跳转页面,当textarea再次聚焦的时候,再点击提交就没问题,可以跳转页面。或者把textarea放在最下面,依然是自上而下输入,提交没问题,可以跳转页面(真机)。请各位大神给解释解释这是肿么回事 <view class="wrap"> <form bindsubmit="formSubmit" class="formSubmit"> <view> <text>稿件主题</text> <textarea class="title" type="text" name="name" placeholder-style="font-size:16px;line-height:20px;color:#ccc;" placeholder="请填写稿件主题" value="" auto-height /><!--这是个文本域,多行文本输入--> </view> <view> <text>联系人</text> <input type="text" name="link_man" placeholder-style="font-size:16px;color:#ccc;" placeholder="请填写联系人" value="" /> </view> <view> <text>联系电话</text> <input type="number" name="link_phone" placeholder-style="font-size:16px;color:#ccc;" placeholder="请填写联系电话或手机号" value="" /> </view> <view> <text>联系邮箱</text> <input type="text" name="link_email" placeholder-style="font-size:16px;color:#ccc;" placeholder="请填写联系邮箱" value="" /> </view> <view class="btn"> <button formType="submit" type="warn" hover-class="none">我要定制</button> </view> </form> </view> .wrap{ height: auto; padding: 0 36rpx; border-top: 1px solid #e0e0e0; border-bottom: none; } view{ display: flex; line-height: 90rpx; border-bottom: 1px solid #f5f5f5; } text{ width: 150rpx; font-size: 32rpx; letter-spacing: 2rpx; } input{ width: 528rpx; height: 90rpx; line-height: 90rpx; font-size: 32rpx; font-family: "Microsoft YaHei"; } .title{ height: auto; min-height: 40rpx; line-height: 40rpx; margin: 0; padding-top: 26rpx; } textarea{ width: 528rpx; min-height: 416rpx; line-height: 52rpx; margin-top: 20rpx; font-size: 32rpx; } .btn{ margin-top: 73rpx; justify-content: center; border: none; } .btn button{ font-size: 28rpx; } // 这是js代码 var app = getApp(); Page({ data: { }, onLoad: function (options) { }, formSubmit: function (e) { var that = this; var token = wx.getStorageSync('token'); var service_type = this.options.type; var formData = e.detail.value; if(formData.name==""){ wx.showToast({ title:"请填写稿件名称", image:"../../images/warring.png" }) } else if (formData.link_man == ""){ wx.showToast({ title: "请填写联系人", image: "../../images/warring.png" }) } else if (formData.link_phone == ""){ wx.showToast({ title: "请填写联系电话", image: "../../images/warring.png" }) } else if (formData.link_email == ""){ wx.showToast({ title: "请填写邮箱", image: "../../images/warring.png" }) } if (formData.name !== "" & formData.link_man !== "" & formData.link_phone !== "" & formData.link_email !== ""){ wx.request({ url: app.urls + 'api/applet/v1/promotion/contribute/save', data:{ token:token, service_type:service_type, name:formData.name, link_man:formData.link_man, link_phone:formData.link_phone, link_email:formData.link_email }, header: { 'Content-Type': 'application/x-www-form-urlencoded' }, method:"POST", success:function(res){ console.log(res.data) if(res.data.retCode == 0){ wx.navigateTo({ url: "writer-order?order_id=" + res.data.data.order_id + '&type=' + service_type }) }else{ wx.showToast({ title: res.data.msg, image: "../../images/warring.png" }) } } }) } } }) |
这是在真机上的图片
初始界面 ,准备输入
<ignore_js_op style=“word-wrap: break-word;”>
自上而下输入完毕,点击我要定制,不会跳转页面
<ignore_js_op style=“word-wrap: break-word;”>
当textarea再次获得焦点,再点击我要定制或完成才会提交成功
</ignore_js_op><ignore_js_op style=“word-wrap: break-word;”>
提交成功后跳转的页面
</ignore_js_op>