【发布时间】:2017-12-04 15:50:52
【问题描述】:
我需要根据元素本身的值来验证列表中的元素。
是否可以或应该为每个产品创建验证?
new Vue({
el: "#app",
data: {
text: '',
sons: [
{amount: 20, pending: 50},
{amount: 30, pending: 150}
]
},
validations: {
text: {
required,
minLength: minLength(5)
},
sons: {
minLength: 3,
$each: {
amount: {
maxValue: maxValue(this.sons[x].pending) // how to set x?
}
}
}
}
})
【问题讨论】: