fix: bug修复
This commit is contained in:
1 parent
1dfddbf1da
commit
22f6bd7ff5
7 files changed
+53
-48
No files matched your search
@@ -12,6 +12,10 @@ const emits = defineEmits<{
|
||||
'update:modelValue': [string | number]
|
||||
}>()
|
||||
|
||||
if (props.options.length && !props.modelValue) {
|
||||
emits('update:modelValue', props.options[0].value)
|
||||
}
|
||||
|
||||
function bindPickerChange(e: { detail: { value: number | string } }) {
|
||||
const currentIndex = e.detail.value as number
|
||||
emits('update:modelValue', props.options[currentIndex].value)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { UniPopupDialogInstance } from '@uni-helper/uni-types'
|
||||
import type { UniPopupInstance } from '@uni-helper/uni-ui-types'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
withDefaults(defineProps<{
|
||||
modelValue: string | number
|
||||
placeholder?: string
|
||||
suffix?: string
|
||||
@@ -10,47 +7,18 @@ const props = withDefaults(defineProps<{
|
||||
placeholder: '请输入内容',
|
||||
})
|
||||
|
||||
const emits = defineEmits<{
|
||||
defineEmits<{
|
||||
'update:modelValue': [string | number]
|
||||
}>()
|
||||
|
||||
const uniPopupRef = ref<UniPopupInstance | null>(null)
|
||||
const uniPopupDialogRef = ref<UniPopupDialogInstance | null>(null)
|
||||
|
||||
function dialogInputConfirm(value: any) {
|
||||
if (value === '') {
|
||||
uni.showToast({
|
||||
title: props.placeholder,
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
emits('update:modelValue', value as (string | number))
|
||||
if (uniPopupRef.value && uniPopupRef.value.close) {
|
||||
uniPopupRef.value.close()
|
||||
}
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
if (uniPopupRef.value && uniPopupRef.value.open) {
|
||||
uniPopupRef.value.open()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-full" @click="handleClick">
|
||||
{{ modelValue }}
|
||||
<view class="w-full flex items-center gap-2">
|
||||
<input class="text-right" :value="modelValue" :placeholder="placeholder" @input="$emit('update:modelValue', modelValue)">
|
||||
<text v-if="suffix">
|
||||
{{ suffix }}
|
||||
</text>
|
||||
</view>
|
||||
<uni-popup ref="uniPopupRef" type="dialog">
|
||||
<uni-popup-dialog
|
||||
ref="uniPopupDialogRef" mode="input" title="输入内容" :value="modelValue" :placeholder="placeholder"
|
||||
@confirm="dialogInputConfirm"
|
||||
/>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in new issue
Block a user