天天看點

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的下标。

描述有誤的地方歡迎大家指正,大家有問題可加qq 876942434。一起進步~