一个页面的form表单,之前还好好的,填加了一些内容后,突然点击提交按钮不起作用了,也不报错,就是点击提交按钮没有任何反应,将整个formSumbit()注释点,从新写一个最简单formSumbit()就是console一下提交内容,依然没有反应。一开始我以为是页面哪里错了,反复了看了反复编译执行,系统也没有报错,也没有错,就是点击提交按钮,没有任何反应。
但是最奇怪的是,不管是手机预览,还是真机调试,在手机上点击提交按钮都能正常提交,这是为什么呢?如果开发真工具点击没有反应,为什么手机预览又可以正常运行,这样我在电脑上就没法调试了!
请各位老师指点!!谢谢!
不好意思,没有上代码,我把全部这个页面的代码上传如下,请老师指点:
// pages/dangchu/dangchu.js
import WxValidate from '../../utils/WxValidate.js';
const db = wx.cloud.database()
Page({
/**
* 页面的初始数据
*/
data: {
punishment_date: '2022-01-01',
date: {
year: '',
month: '',
day: ''
},
certificateID1: '',
certificateID2: '',
// 模糊查询时长
timer: 0,
// 点击结果项之后替换到文本框的值
inputValue: '',
// 是否隐藏模糊查询的面板
hideScroll: true,
// 模糊查询结果
searchTip: []
},
onInput(e) {
const inputValue = e.detail.value
clearTimeout(this.data.timer)
let timer = setTimeout(() => {
if (inputValue) {
// 如果输入的关键字不为空,则发起请求获取联想值
var that = this; //这句不能少,在查询时
const legalTerms = db.collection('legalTerms').where({
behavior:{
$regex:'.*'+ inputValue,
$options: 'i'
}
}).get({
success(res) {
console.log('查询成功', res.data);
//将查询返回的结果赋值给本地变量
that.setData({
searchTip: res.data,
inputValue: inputValue,
hideScroll: false
})
console.log('查询成功', that.data.searchTip);
},
fail: err => {
console.log('失败')
}
})
}
// 如果为空,则收起
this.setData({
searchTip: [],
hideScroll: true,
// inputValue: ''
})
}, 600)
this.data.timer = timer
},
itemtap(e) {
const { info } = e.currentTarget.dataset
console.log('选择的ID是',info)
this.setData({
// 将点击选择的值展示在input框中
inputValue: info.behavior,
illegalLawName: info.illegalLawName,
illegalTitle: info.illegalTitle,
punishLawName: info.punishLawName,
punishTitle: info.punishTitle,
// 当用户选择某个联想词,隐藏下拉列表
hideScroll: true
})
},
showToast(error) {
wx.showToast({
title: error.msg,
icon: 'none'
})
},
initValidate() {
const rules = {
officers_name1: {
required: true
},
officers_name2: {
required: true,
},
document_number: {
required: true,
},
}
const messages = {
officers_name1: {
required: '请输入执法人员姓名',
},
officers_name2: {
required: '请输入执法人员姓名',
},
document_number: {
required: '请输入文书编号',
},
// boxType: {
// required: '请选择箱型',
// },
// boxCount: {
// required: '请输入发单数量',
// intType: '发单数量请输入10以内'
// },
// weight: {
// required: '请输入箱重',
// weight: '箱重请填写100以内整数或两位小数'
// },
// store: {
// required: '请输入门点地址',
// },
// harbour: {
// required: '请输入港区',
// },
// freight: {
// required: '请输入运费金额',
// money: '请输入正确的金额'
// },
// freshInterval: {
// required: '请选择重发间隔',
// },
// linkman: {
// required: '请选择联系人',
}
this.WxValidate = new WxValidate(rules, messages)
},
bindDateChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail)
this.setData({
punishment_date: e.detail.value
})
},
// formSubmit(e) {
// console.log('form发生了submit事件,携带数据为:', e.detail.value)
// },
formSubmit(e) {
var that = this
console.log('form发生了submit事件,携带数据为:', e.detail.value)
const params = e.detail.value
// 校验表单
if (!this.WxValidate.checkForm(params)) {
console.log(this.WxValidate.errorList[0])
const error = this.WxValidate.errorList[0]
this.showToast(error)
return false
}
var date = new Date(e.detail.value.punishment_date)
var year = date.getFullYear()
var month = date.getMonth()+1
var day = date.getDate()
this.setData({
date: {
year: year,
month: month,
day: day
}
})
const certificate1 = db.collection('certificate').where({
name: e.detail.value.officers_name1
})
.get().then(res=>{
this.setData({
certificateID1: res.data[0].certificateID
})
console.log('当前数据库返回的是:',res.data[0].certificateID)
const certificate2 = db.collection('certificate').where({
name: e.detail.value.officers_name2
})
.get().then(res=>{
this.setData({
certificateID2: res.data[0].certificateID
})
console.log('当前数据库返回的是:',res.data[0].certificateID)
wx.setStorageSync('dangchu_result',{
business_address: e.detail.value.business_address,
enterprise_name: e.detail.value.enterprise_name,
idCardNO: e.detail.value.idCardNO,
person_name: e.detail.value.person_name,
punishment_address: e.detail.value.punishment_address,
reg_num: e.detail.value.reg_num,
telNO: e.detail.value.telNO,
officers_name1: e.detail.value.officers_name1,
officers_name2: e.detail.value.officers_name2,
illegal_behavior: e.detail.value.illegal_behavior,
document_number: e.detail.value.document_number,
punishment_day: that.data.date.day,
punishment_month: that.data.date.month,
punishment_year: that.data.date.year,
certificateID1: that.data.certificateID1,
certificateID2: that.data.certificateID2,
illegalLawName: that.data.illegalLawName,
illegalTitle: that.data.illegalTitle,
punishLawName: that.data.punishLawName,
punishTitle: that.data.punishTitle,
})
wx.navigateTo({
url: '../handWrite/handWrite',
})
})
.catch(res=>{
// 处理执法人员2输入错误
console.log('发生错误!', res),
wx.showToast({
title: '输入的执法人员2不存在',
icon: 'none'
})
})
})
.catch(res=>{
// 处理执法人员1输入错误
console.log('发生错误!', res),
wx.showToast({
title: '输入的执法人员1不存在',
icon: 'none'
})
})
},
getStorage(){
// var that=this
var business= wx.getStorageSync('business')
var idCard= wx.getStorageSync('idCard')
this.setData({
enterprise_name: business.enterprise_name,
reg_num: business.reg_num,
business_address: business.business_address,
person_name: business.person_name,
idCardNO: idCard.idCardNO,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.initValidate()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getStorage()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
<!--pages/dangchu/dangchu.wxml-->
<form bindsubmit="formSubmit" bindreset="formReset">
<view class="chapter">
<view class="chapter__title">当事人基本信息</view>
<view class="section">
<view class="section__title">请输入当事人名称</view>
<input class="ordinaryInput" name="enterprise_name" focus="true" value="{{enterprise_name}}"/>
</view>
<view class="section">
<view class="section__title">请输入统一社会信用代码</view>
<input class="ordinaryInput" name="reg_num" value="{{reg_num}}"/>
</view>
<view class="section">
<view class="section__title">请输入住所地址</view>
<input class="ordinaryInput" name="business_address" value="{{business_address}}"/>
</view>
<view class="section">
<view class="section__title">请输入法定代表人姓名</view>
<input class="ordinaryInput" name="person_name" value="{{person_name}}"/>
</view>
<view class="section">
<view class="section__title">请输入法人身份证号</view>
<input class="ordinaryInput" name="idCardNO" type="idcard" value="{{idCardNO}}"/>
</view>
<view class="section">
<view class="section__title">请输入法人联系电话</view>
<input class="ordinaryInput" name="telNO" type="number"/>
</view>
</view>
<view class="chapter">
<view class="chapter__title">处罚基本信息</view>
<view class="section">
<view class="section__title">请输入文书编号</view>
<input class="ordinaryInput" name="document_number" type="number"/>
</view>
<view class="section_two">
<view class="section__title">请输入执法人员姓名</view>
<view class="twoInputBox">
<input class="twoInput" name="officers_name1" />
<input class="twoInput" name="officers_name2" />
</view>
</view>
<view class="section" style="clear: both;">
<view class="section__title">请输入处罚地点</view>
<input class="ordinaryInput" name="punishment_address" value="{{business_address}}"/>
</view>
<view class="section">
<view class="section__title">请选择当前日期</view>
<picker name="punishment_date" mode="date" start="2015-09-01" end="2025-12-01" bindchange="bindDateChange">
<view class="picker">
{{punishment_date}}
<view class='arrow'></view>
</view>
</picker>
</view>
<view class="section">
<view class="section__title">请输入违法行为</view>
<input class="ordinaryInput" name="illegal_behavior" value="{{inputValue}}" focus='true' confirm-type="search" placeholder="请输入违法行为的主要关键字" bindinput="onInput" />
<view class="line"></view>
<scroll-view scroll-y="true" class="search-res" hidden="{{hideScroll}}">
<view class="sum">共找到和“{{inputValue}}”相关的结果{{searchTip.length}}个</view>
<block wx:for="{{searchTip}}" wx:key="_id">
<view class="tip-item" bindtap="itemtap" data-info="{{item}}">
<view class="left">
<view class="tip">
<view>{{item.illegalLawName}}</view>
<view>{{item.illegalTitle}}</view>
</view>
<view class="content">
{{item.illegalContent}}
</view>
</view>
</view>
</block>
</scroll-view>
</view>
</view>
<button formType="submit" class="End_button" type="primary">提交</button>
</form>
<view class="line"></view>
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
啥也看不见,咋猜