チェックボックスの状態をemitで親にバケツリレーするように

This commit is contained in:
rca 2024-07-22 05:59:17 +09:00
parent 8b1e5ad87f
commit 7788508af5
2 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<template>
<div class="text-h6" style="display: flex; justify-content: space-between; align-items: center;">
<span>過去のお手伝い</span>
<q-checkbox v-model="allChecked"></q-checkbox>
<q-checkbox v-model="containPaid"></q-checkbox>
</div>
<q-list padding>
<q-item v-for="(history, index) in props.histories" :key="index" clickable>
@ -20,7 +20,7 @@
<script setup lang="ts">
import { HistoryItem } from 'src/models/internal';
import { ref } from 'vue';
import { ref, watch } from 'vue';
interface Props {
histories: HistoryItem[];
@ -28,8 +28,14 @@ interface Props {
// Props
const props = defineProps<Props>();
const emit = defineEmits(['containPaid:checked']);
const allChecked = ref(false);
const containPaid = ref(false);
watch(() => containPaid.value, (value) => {
console.log(value);
emit('containPaid:checked', value);
});
</script>

View File

@ -1,7 +1,7 @@
<template>
<QCard class="q-ma-md">
<QCardSection>
<HistoryComponent :histories=props.histories />
<HistoryComponent :histories=props.histories @containPaid:checked="handleContainPaidCheckbox"/>
</QCardSection>
</QCard>
</template>
@ -17,4 +17,8 @@ interface Props {
const props = defineProps<Props>();
const handleContainPaidCheckbox = (value: boolean) => {
console.log(value);
};
</script>