誤ったmodelValueの使用法の修正

This commit is contained in:
Mouriya
2024-05-27 19:52:16 +09:00
parent f2ab310b6d
commit c398dee21e

View File

@@ -4,12 +4,11 @@
<template v-slot:control> <template v-slot:control>
<q-card flat class="full-width"> <q-card flat class="full-width">
<q-card-actions vertical> <q-card-actions vertical>
<q-btn color="grey-3" text-color="black" <q-btn color="grey-3" text-color="black" @click="() => { dgIsShow = true }">APP SELECT</q-btn>
@click="() => { dgIsShow = true }">APP SELECT</q-btn>
</q-card-actions> </q-card-actions>
<q-card-section class="text-caption"> <q-card-section class="text-caption">
<div v-if="selectedField"> <div v-if="selectedField.app.name">
{{ selectedField.name }} {{ selectedField.app.name }}
</div> </div>
<div v-else>{{ placeholder }}</div> <div v-else>{{ placeholder }}</div>
</q-card-section> </q-card-section>
@@ -31,7 +30,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, ref, watchEffect } from 'vue'; import { computed, defineComponent, reactive, ref, watchEffect } from 'vue';
import ShowDialog from '../ShowDialog.vue'; import ShowDialog from '../ShowDialog.vue';
import AppSelectBox from '../AppSelectBox.vue'; import AppSelectBox from '../AppSelectBox.vue';
@@ -68,22 +67,18 @@ export default defineComponent({
setup(props, { emit }) { setup(props, { emit }) {
const appDg = ref() const appDg = ref()
const dgIsShow = ref(false) const dgIsShow = ref(false)
const selectedField = ref() const selectedField = props.modelValue && props.modelValue.app ? props.modelValue : reactive({app:{}});
const closeDg = (state: string) => { const closeDg = (state: string) => {
dgIsShow.value = false; dgIsShow.value = false;
if (state == 'OK') { if (state == 'OK') {
selectedField.value = appDg.value.selected[0]; selectedField.app = appDg.value.selected[0];
} }
}; };
console.log(selectedField);
// console.log(props);
watchEffect(() => { watchEffect(() => {
emit('update:modelValue', { app: selectedField.value }); emit('update:modelValue', selectedField);
}); });
return { return {