Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Convert String into Integer using Vuejs, vuex? [duplicate]

I have a Little Problem with my application. I am currently making a Basic stock Trader app (as an exercise). I am using Vuejs and Vuex. In my store.js file I am storing all the global variables but there is this problem with the bmw_quantity data. It is mapped to a v-model (Input field) which you can see in the stocks.vue component. For some reasons the data is always a string. I don't know why and I also tried several things but I couldn't convert the things I type in the field into an actual integer and not a string.

Here is my code:

image 1

image 2

like image 286
John Kohlmeier Avatar asked Dec 17 '18 20:12

John Kohlmeier


1 Answers

You can use the .number modifier: https://vuejs.org/v2/guide/forms.html#number

<input v-model.number="bmw_quantity" type="number">
like image 165
sandrooco Avatar answered Oct 20 '22 04:10

sandrooco