use define model
This commit is contained in:
@@ -1,22 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { evepraisalAxiosInstance } from '@/market/appraisal/evepraisal';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
|
||||
interface Props {
|
||||
name: string;
|
||||
modelValue?: string;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: string): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: ''
|
||||
});
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const value = useVModel(props, 'modelValue', emit);
|
||||
const modelValue = defineModel({ default: '' });
|
||||
defineProps<Props>();
|
||||
|
||||
const loadFromId = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement;
|
||||
@@ -31,7 +21,7 @@ const loadFromId = async (e: Event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
value.value = JSON.stringify(response.data);
|
||||
modelValue.value = JSON.stringify(response.data);
|
||||
input.value = '';
|
||||
}
|
||||
</script>
|
||||
@@ -39,6 +29,6 @@ const loadFromId = async (e: Event) => {
|
||||
<template>
|
||||
<div class="flex-1 mx-1">
|
||||
<span>{{ name }}</span><input type="text" class="ms-2" @change="loadFromId" placeholder="id evepraisal" />
|
||||
<textarea class="mt-1" v-model="value" />
|
||||
<textarea class="mt-1" v-model="modelValue" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user