Skip to content

Instantly share code, notes, and snippets.

@cbdyzj
Last active April 9, 2022 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbdyzj/acfaf1c8e836c7cea35d95b03421e88d to your computer and use it in GitHub Desktop.
Save cbdyzj/acfaf1c8e836c7cea35d95b03421e88d to your computer and use it in GitHub Desktop.
PriceInput.vue
<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