uniapp使用uview组件库的表单校验失效的解决方案,由于页面生命周期与组件生命周期不同,若都使用onReady会导致H5或APP无法校验表单的情况。
解决方案
若在页面中使用表单校验
onReady() {
this.$refs.uForm.setRules(this.rules);
}
若在组件中使用表单校验
mounted() {
this.$refs.uForm.setRules(this.rules);
}
页面生命周期与组件生命周期不同,若都使用onReady会导致H5或APP无法校验表单的情况。