Vue converts input[type=number] to a string value

后端 未结 2 1806
春和景丽
春和景丽 2020-12-01 15:42

I\'m running into the problem, that Vue converts the value of an input field of type number into a string and I just can\'t figure out why. The guide I am following along do

2条回答
  •  忘掉有多难
    2020-12-01 16:02

    Change the order object to :

    const order = {
        stockId: this.stock.id,
        stockPrice: this.stock.price,
        quantity: +this.quantity
    };
    

    This will automatically parse the string to a number.

    In general the data from HTML inputs are strings. The input type only checks if a valid string has been provided in the field.

提交回复
热议问题