[Vuejs]-Vue.js – Value is concatenated instead of added

0👍

Calling toFixed() in your setCosts method returns a string. So you are adding two strings, which results in a concatenated string.

If you want item.cost as a numeric value, you can use the unary plus like this:

item.cost = +((d + c).toFixed(2));

Leave a comment