我找到了正确的解决方案:
HTML代码
<input type="text" name="mobilePhone" class="form-control" v-model="form.mobilePhone" v-validate ="{ rules: { required: contactInfo} }" :class="{'input': true, 'is-danger': errors.has('mobilePhone') }">
<input type="text" name="emailAddress" class="form-control" v-model="form.emailAddress" v-validate ="{ rules: { required: contactInfo} }" :class="{'input': true, 'is-danger': errors.has('emailAddress') }">
<input type="text" name="phoneNumber" class="form-control" v-model="form.phoneNumber" v-validate ="{ rules: { required: contactInfo} }" :class="{'input': true, 'is-danger': errors.has('phoneNumber') }">
JS计算代码
computed: {
contactInfo () {
if (this.form.phoneNumber || this.form.mobilePhone || this.form.emailAddress) {
return false
}
else {
return true
}
}
}