gpt4 book ai didi

vue.js - Vuetify - 如何正确验证复选框组

转载 作者:搜寻专家 更新时间:2023-10-30 22:18:21 24 4
gpt4 key购买 nike

是否有可能以与 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com