Last active
April 9, 2022 12:27
-
-
Save cbdyzj/acfaf1c8e836c7cea35d95b03421e88d to your computer and use it in GitHub Desktop.
PriceInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<input type="text" | |
inputmode="numeric" | |
:value="editing ? value : formattedValue" | |
@focus="editing = true" | |
@blur="editing = false" | |
@input="value = $event.target.value" | |
placeholder="Enter" | |
pattern="[0-9]*"/> | |
</template> | |
<script setup> | |
import { computed, ref } from 'vue' | |
const editing = ref(false) | |
const value = ref('') | |
const formattedValue = computed(() => { | |
return value.value && Number(value.value).toLocaleString() | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment