uniapp+uview中出现两个表单时都需要做必填校验

解决:切换另个一个表单事件中或者打开模态框的事件中,用this.$nextTick(function(){})重新设置。

onReady() {
	this.$refs.registerForm.setRules(this.registerRules);
},
methods:{
    // 切换tab
	cutTab(type){
		this.activeIndex = type
		if(type === 1){
			this.$nextTick(function(){
				this.$refs.firmRegisterForm.setRules(this.firmRegisterRules);
			})
		}else{
			this.$nextTick(function(){
				this.$refs.registerForm.setRules(this.registerRules);
			})
		}
	},
}

猜你喜欢

转载自blog.csdn.net/weixin_58101575/article/details/123047929