由于我项目的原因,企业和个人个表单不一样,通过给isView的true和false来控制
首先企业默认的是true,所以可以在created里面判断
created() {
if (this.isView) {
// 个人表单校验失效
this.rules.personName[0].required = false
// 或者这样写也可以
this.$refs['formName'].clearValidate('xxx')
}
},
然后再在methods方法里面点击了企业个人表单按钮时再判断
handelPerson() {
this.isView = false
if (!this.isView) {
// 企业表单校验失效
this.rules.pwuName[0].required = false
this.rules.personName[0].required = true
// 或者这样写也可以
this.$refs['formName'].clearValidate('xxx')
}
},