A
A
Anton89892020-12-14 23:54:31
Vue.js
Anton8989, 2020-12-14 23:54:31

How to make only one checkbox alternately selected?

Good day) It is necessary that when you click on the Second checkbox, the checkbox is unchecked from the First one, and vice versa) Can someone help) Thank you) Here is the code:

<template lang="pug">
div
  div(v-for='item in items')
    v-checkbox(v-model='item.checked' :label='item.text' :value='item.id' hide-details='')
</template>

<script>
export default {
  data () {
    return {
      checked: true,
      items: [
        {text: 'Первый1', checked: true},
        {text: 'Первый2', checked: false},
      ]
    }
  }
}
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-12-14
@Anton8989

Well, this is how to code:
By clicking on the second checkbox - remove from the first
And vice versa.
In general, use type="radio"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question