var WxValidate =require('../../../utils/WxValidate.js')
const App = getApp()
Page({
data: {
form:{
name_company:'',
},
},
onLoad() {
this.initValidate() //验证规则函数
},
//报错
showModal(error){
wx.showModal({
content:error.msg,
showCancel:false,
})
},
//验证函数
initValidate(){
const rules={
name_company:{
required:true,
},
}
const messages={
name_company:{
required:'请输入企业名称',
},
}
this.WxValidate = new WxValidate(rules,messages)
},
formSubmit:function(e){
const params=e.detail.value
console.log(params)
//传入表单数据,调用验证方法
if(!this.WxValidate.checkForm(params)){
const error=this.WxValidate.errorList[0]
this.showModal(error)
return false
}
this.showModal({
msg:'提交成功'
})
},
})
想在表单提交前验证必填项,引入WxValidate.js,出现了这个的错误,请问要怎么解决