我如何在vuetify 3中有一个十进制输入,允许.
作为输入,这样我就可以写例如“123.45”?
我的当前代码:MyNumberInput.vue
:
<template>
<v-text-field v-model="value" type="number" :label="label" outlined />
</template>
<script setup lang="ts">
import { computed } from "vue";
const props = defineProps<{
label: string;
modelValue: number;
}>();
const emit = defineEmits(["update:modelValue"]);
const value = computed({
get: (): number => props.modelValue,
set: (value: number) => {
// value is type string actually and when `.` is entered I get NaN
emit("update:modelValue", value); // won't work as it returns the value which is of type string or NaN
},
});
</script>
字符串
1条答案
按热度按时间nbewdwxp1#
我想现在这样可以了
字符串