7

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

1
  • 4
    Always post your code as text (and format it as code), not screenshots! This is really important to find problems again. Commented Dec 17, 2018 at 20:19

1 Answer 1

16

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

<input v-model.number="bmw_quantity" type="number">
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very very much. I am quite knew to this (6 months) and still not knowing sooo much Things. You saved my evening. :)
It‘s alright, that‘s why I‘m telling you. :) Please mark as solved when it works.
Dear @JohnKohlmeier... Please spare a few seconds to mark correct answer! Developers like me will feel easy to find such solutions.
@JohnKohlmeier , please indeed mark the answer if possible. Not only it will allow for easier searches, and the answer itself is valid, I believe, but the mark will reward the one who invested their priceless time for it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.