在Vue组件中,我有3个数字字段,如下所示:
data() {
return {
numberAdults: 0,numberChildren: 0,numberInfants: 0,}
以及计算所得的属性:
computed: {
numberPersons() {
return this.numberAdults + this.numberChildren + this.numberInfants
},
我想验证是否设置了至少一个人(至少一个成人或一个孩子或一个婴儿),但是我无法使其工作。这是验证规则:
numberPersons: {
required,minValue: minValue(1),},
如果我用三个字段之一更改numberPersons
,则对该字段的验证有效。我认为Vuelidate不知道numberPersons
是什么,但我不确定如何更改。