[Vuejs]-How to store label text in array from checkbox in vue js

0👍

This one works great

<script setup>
import { ref } from 'vue'

const add_info = ref([])
</script>

<template>
  <div>
    <p>array of checked labels {{ add_info }}</p>
    <input type="checkbox" id="checkbox" v-model="add_info" value="coolLabel" />
    <label for="coolLabel">This is a cool label!</label>
  </div>
</template>

As shown here

PS: you can also of course have coolLabel as another ref if you want to have it reusable.

Leave a comment