Skip to content

Instantly share code, notes, and snippets.

@wisetc
Created November 10, 2017 07:56
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 wisetc/16994a6a26b438a7264454d856374149 to your computer and use it in GitHub Desktop.
Save wisetc/16994a6a26b438a7264454d856374149 to your computer and use it in GitHub Desktop.
Use vuejs watch feature to force the input to input Integer only and not float is allowed.
watch: {
'form.amount'(val, oldVal) {
if (!Number.isInteger(val)) {
this.$nextTick(() => {
this.form.amount = parseInt(val, 10)
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment