This string returns the value: Pressure 770.3157279 mm
<div class="info">Pressure {{info.main.pressure * 0.750064}} mm </div>
How do I make the number become an integer and get:
Pressure 770 mm
This string returns the value: Pressure 770.3157279 mm
<div class="info">Pressure {{info.main.pressure * 0.750064}} mm </div>
How do I make the number become an integer and get:
Pressure 770 mm
You can use parseInt
<div class="info">Pressure {{ parseInt(info.main.pressure * 0.750064) }} mm </div>
To convert any value to an integer, just wrap it into:
parseInt(yourValue)
You are ready to go.
To convert any value to an integer, just wrap it into:
Number(yourValue);
You can do it like this:
<div class="info">Pressure {{(info.main.pressure * 0.750064).toFixed() }} mm </div>
In the code of Vue 2.7, the v-model.number
modifier casts values to numbers like this:
function toNumber(val) {
var n = parseFloat(val);
return isNaN(n) ? val : n;
}
© 2022 - 2024 — McMap. All rights reserved.
parseInt(yourValue, 10)
at the very least. – Protuberancy