0👍
toFixed()
is returning a string and not a number.
For better readability I would extract the logic in an own function aswell
EDIT: added Math
instead of toFixed
you could write a function which transform your number into a decimal.
const transformNumber = (number) => {
return Math.trunc(number * 10000)/10000;
}
and like mentioned a computed property:
computed: {
reward(): {
return transformNumber(myAcccount.reward.accrued) * (10 ** -9) - transformNumber(appAcccount.reward.paid) * (10 ** -9)
}
}
0👍
You can try applying .toFixed() to the end of the calculation by enclosing the math part inside ().
<div class="mb-2">Reward: {{ (myAcccount.reward.accrued * (10 ** -9) - appAcccount.reward.paid * (10 ** -9)).toFixed(4)}}</div>
- [Vuejs]-Option Group can't be selected in quasar 2 / Vue 3 when trying to migrate from quasar 1 /vue 2
- [Vuejs]-How do I scope nuxt-link-exact-active only for particular page in nuxt?
Source:stackexchange.com