微信小程序做form表單提交,我在form組件的submit函數(shù)里調(diào)用每個input綁定的失焦事件,在提交表單前驗證下每個input數(shù)據(jù),但是發(fā)現(xiàn)直接調(diào)用失焦事件的話會報錯,具體代碼如下:<form bindsubmit='submit'><input placeholder="請輸入姓名" bindblur="checkName"/><input placeholder="請輸入密碼" bindblur="checkPassword"/><button form-type='submit'>提交</button></form>Page({ data: { name: '', password: '' }, checkName:function (e) { //這里正則驗證輸入數(shù)據(jù) console.log(e.detail.value); if(驗證通過){ return true; } return false; }, checkPassword:function(e) { //這里正則驗證輸入數(shù)據(jù) console.log(e.detail.value); if(驗證通過){ return true; } return false; }, submit:function (e) { if (!this.checkName()) return if (!this.checkPassword()) return }})報錯為:Cannot read property 'detail' of undefined;at pages/index/index page checkName functionTypeError: Cannot read property 'detail' of undefined不在submit里調(diào)用那幾個失焦函數(shù)的話,正常input失焦可以打印e.detail.value的,但為啥調(diào)了就報錯了
小程序的form的submit函數(shù)里調(diào)用input的失焦事件會報錯,求指導
阿晨1998
2019-03-27 18:19:33