fix: 修复取件码输入框的响应式数据流问题
This commit is contained in:
@@ -59,7 +59,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, inject, watch } from 'vue'
|
import { ref, inject, computed } from 'vue'
|
||||||
import { ArrowRightIcon } from 'lucide-vue-next'
|
import { ArrowRightIcon } from 'lucide-vue-next'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
@@ -73,25 +73,25 @@ interface InputStatus {
|
|||||||
interface Props {
|
interface Props {
|
||||||
inputStatus: InputStatus
|
inputStatus: InputStatus
|
||||||
error?: boolean
|
error?: boolean
|
||||||
|
modelValue: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
submit: []
|
submit: []
|
||||||
'update:code': [value: string]
|
'update:modelValue': [value: string]
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
const emit = defineEmits<Emits>()
|
const emit = defineEmits<Emits>()
|
||||||
|
|
||||||
const isDarkMode = inject('isDarkMode')
|
const isDarkMode = inject('isDarkMode')
|
||||||
const code = ref('')
|
const code = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (value) => emit('update:modelValue', value)
|
||||||
|
})
|
||||||
const isInputFocused = ref(false)
|
const isInputFocused = ref(false)
|
||||||
const codeInput = ref<HTMLInputElement>()
|
const codeInput = ref<HTMLInputElement>()
|
||||||
|
|
||||||
watch(code, (newValue) => {
|
|
||||||
emit('update:code', newValue)
|
|
||||||
})
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
focus: () => codeInput.value?.focus()
|
focus: () => codeInput.value?.focus()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
<div class="p-8">
|
<div class="p-8">
|
||||||
<PageHeader :title="config.name" @title-click="toSend" />
|
<PageHeader :title="config.name" @title-click="toSend" />
|
||||||
<RetrieveForm
|
<RetrieveForm
|
||||||
|
v-model="code"
|
||||||
:input-status="inputStatus"
|
:input-status="inputStatus"
|
||||||
:error="!!error"
|
:error="!!error"
|
||||||
@submit="handleSubmit"
|
@submit="handleSubmit"
|
||||||
@update:code="code = $event"
|
|
||||||
ref="retrieveFormRef"
|
ref="retrieveFormRef"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user