Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get the updated value on every keystroke rather than when a change event is emitted? #22

Closed
martinnobis opened this issue Jul 24, 2022 · 1 comment

Comments

@martinnobis
Copy link

The v-model variable is currently only updated when the change event occurs, but would it instead be possible to update at each keystroke? e.g. in the playground you can see that the new value only gets updated when the focus disappears from the input. Can we update it at each keystroke instead? Thanks.

@dipaksarkar
Copy link
Contributor

Yes, You can use @input:model-value event for Vue 3.0 and @input for Vue 2.0

Example for Vue 3.0 (where make sure that you using @coders-tm/vue-number-format latest version)

<template>
  <div><VueNumberFormat :model-value="price" @input:model-value="(val) => (price = val)" v-bind="number"></VueNumberFormat> {{price}}</div>
</template>

<script>
  import { number as VueNumberFormat } from '@coders-tm/vue-number-format'

  export default {
    components: {
      VueNumberFormat,
    },

    data() {
      return {
        price: 123.45,
        number: {
          decimal: '.',
          separator: ',',
          prefix: '$ ',
          precision: 2,
          masked: false,
        },
      }
    },
  }
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants