In vue, the radio binding problem with the checkbox

In the

vue project, using the radio box, v-model binds an array. When the array is empty, the radio box is still selected.

<input type="radio" v-model="arr"/>

data() {
    return {
        arr: []
    }
}

how to modify it, when emptying the array, uncheck the checkbox?

Mar.10,2021

first of all, I don't quite understand why the subject binds an array to radio's v-model, if you want to bind multiple radio? If so, refer to the official instance ide/forms.html-sharp%E5%8D%95%E9%80%89%E6%8C%89%E9%92%AE" rel=" nofollow noreferrer "> official instance

if the subject must bind an array, you can customize an attribute on the array as follows:
js


 data () {
    return {
        arr: []
    };
}

html

 <input type="radio" value="1" v-model="arr.a">
<input type="radio" value="2" v-model="arr.a">
<input type="radio" value="3" v-model="arr.a">

I don't know any other way. If a great god passes by, please give me some advice.


No code word x?

casually write a demo, you can take a look at


Boolean value of empty array or ture, empty arr can be arr='' or null

  • The treatment of multiple groups of radio by vue

    topic description vue s treatment of multiple groups of radio 1. Multiple groups of radio are traversed with v-for, how to traverse multiple groups of radio at once 2. How to get all the radio values at once after traversing multiple groups of radi...

    Apr.05,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b310d5-402ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b310d5-402ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?