是否有可能以与 radio 组相同的方式在 Vuetify 中验证复选框组?我试图“整体”验证它们,但每个复选框都是单独验证的。如何强制选中至少一个复选框字段?
<template>
<v-form v-model="valid" ref="form">
<div v-for="(x, i) in items">
<v-checkbox
:true-value="1"
:false-value="0"
:rules="[v => !!v || 'You must agree to continue!']"
v-model="x"
/>
</div>
</v-form>
<template>
我希望只有一个必填复选框。不是所有的人。他们组中的任何复选框。
最佳答案
试试这个方法:
<template>
<v-form v-model="valid" ref="form">
<div v-for="(x, i) in items">
<v-checkbox
:true-value="1"
:false-value="0"
:rules="[v => v.length > 0 || 'You must agree to continue!']"
v-model="x"
/>
</div>
</v-form>
<template>
关于vue.js - Vuetify - 如何正确验证复选框组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49353774/