I have looked at many examples of how to do two-way binding of model data, but examples with text inputs are reported everywhere. I work according to the same scheme and get errors.
const models = ref({
teams: {
items: usePage().props.value.teams,
selected: [],
isCheckAll: false,
},
});
<template>
<LineTeamsIndex
v-model:selected-items="models.teams.selected"
v-model:isCheckAll="models.teams.isCheckAll"
:teams="$page.props.teams"
@checkAll="checkAll"
>
</LineTeamsIndex>
</template>
child
<script setup>
defineEmits(["update:selectedItems", "update:isCheckAll", "checkAll"]);
const props = defineProps({
teams: Object,
selectedItems: Object,
isCheckAll: Boolean,
});
</script>
<template>
<template v-slot:body>
<tr v-for="team in $page.props.teams.data" :key="team.id">
<td>
<div class="form-check font-size-16">
<input
:id="team.id"
:value="team.id"
:checked="selectedItems.includes(team.id)"
@change="
$emit(
'update:selectedItems',
$event.target.value
)
"
class="form-check-input"
type="checkbox"
/>
</div>
</td>
<td>{{ team.id }}</td>
<td>
{{ team.name }}
</td>
</tr>
</template>
</template>
Here is a part of the code related to the SelectedItems array. Two-way binding via the built-in v-model is required. But it either doesn't work, or I get a data mismatch error " [Vue warn]: Invalid prop: type check failed for prop "SelectedItems". Expected Object, got String with value "88"". Tell me how to correctly transfer (use) the built-in v-model vue 3 to add data to the array and delete using concise code? Despite the fact that in the child component I have 2 models (not one) that are bound in the parent component.