How to stop Vue.js from converting input[type=number] input value to a string value?

Sometimes, we want to stop Vue.js from converting input[type=number] input value to a string value.

In this article, we’ll look at how to stop Vue.js from converting input[type=number] input value to a string value.

How to stop Vue.js from converting input[type=number] input value to a string value?

To stop Vue.js from converting input[type=number] input value to a string value, we can add the number modifier to v-model.

For instance, we write

<template>
  <form>
    <input v-model.number="quantity" type="number" />
  </form>
</template>

to add the number modifier after v-model.

As a result, quantity would be a number instead of a string.

Conclusion

To stop Vue.js from converting input[type=number] input value to a string value, we can add the number modifier to v-model.