How I can create custom checkbox in Vue. And when checkbox is changed, he should call function. I got errors "Cannot read property 'id' of undefined" And warnings "Unhandled error during execution of native event handler "
Custom checkbox:
<template>
<div class="filter">
<input
:ref="id"
:id="id"
type="checkbox"
class="filter-checkbox"
@change="$emit('do', $emit)"
/>
<span></span>
</div>
</template>
<script>
export default {
name: "Checkbox",
props: {
label: {
type: String
},
isSelected: {
type: Boolean
},
id: {
type: String
}
},
}
</script>
How i want to use it inside my parent component:
<Checkbox
v-for="filter of filters"
:key="filter.id"
:label="filter.name"
:id="filter.id"
v-model="filter.selected"
@do="mutuallyExclusive(filter.id)"
/>
Aucun commentaire:
Enregistrer un commentaire