快捷搜索: 王者荣耀 脱发

please transfer a valid prop path to form item 解决

需求:新增或者编辑操作时,需要对表单中嵌套的表格中的属性进行校验。 出现这个错误的愿意是prop的值没有绑定正确。如果只给一个form表单中的某个属性校验,一般prop中就是form中的这个属性,但是当需要form表单中存在一个table,里面的数据是遍历出来的,如果需要对table中的数据的某个字段进行校验时,prop没有办法写死, 比如数组格式是这样子:

model:{
	userInfoList:[{
	   name:xxxx,
	   sex:1
	}]
}

我们要校验userInfoList中的name是否符合要求,由于是遍历出来的,所以需要动态的绑定prop

:prop="userInfoList.+index+.name"

index就是userInfoList的下表 当数据格式是这样子:

model:{
	userInfoList:[
		user:[
			{
			name:xxxx,
			age:12
			}
		]
	]
}

那么绑定prop的时候就在多一层:

:prop="userInfoList.+index1+.user.+index+.name"

这里的index1是userInfoList的下标,index 为user的下标。

经验分享 程序员 微信小程序 职场和发展