Radio in v-for dynamically created



  • I’m trying to dynamically create radio element with server data and v-for, but radio buttons don’t work properly

      <q-item v-for="(item3, index) in MyValues">
         <q-radio v-model="item3.model" :val="item3.val" :label="item3.label"></q-radio>
      </q-item>
    

    json data
    MyValues: [{label: “Radio 1”, model: “selectedIndex”, val:2}, {label: “Radio 2”, model: “selectedIndex”, val:3}]

    After creating both of radio buttons checked and can’t be unchecked. Pls help.



  • Radios are usually a type of selection. In other words, they all share the same model and only one can be selected at any one time. So, you giving them all different models won’t work.

    I think what you are looking for are toggles.

    https://quasar-framework.org/components/toggle.html

    Scott