formatter.vue 312 B

12345678910111213
  1. <template>
  2. <el-input
  3. v-model="input"
  4. placeholder="Please input"
  5. :formatter="(value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
  6. :parser="(value) => value.replace(/\$\s?|(,*)/g, '')"
  7. />
  8. </template>
  9. <script lang="ts" setup>
  10. import { ref } from 'vue'
  11. const input = ref('')
  12. </script>