xlsdg / vue-countup-v2

Vue.js component wrap for countUp.js
https://inorganik.github.io/countUp.js/
MIT License
379 stars 56 forks source link

dynamic decimals not updating #3

Closed eybarta closed 6 years ago

eybarta commented 7 years ago

Hi, great plugin, thanks!

I wanted to use 2 decimals in case my number is a float and 0 decimals in case my number is whole to avoid having numbers like this for example: 1542.00

so I tried as prop on component: <count-up ... :decimals="subtotal % 1 != 0 ? 2 : 0" ... />

and it doesn't work as needed..

could you please let me know how to accomplish what I need?

thx!

xlsdg commented 7 years ago
<template v-if="subtotal % 1 === 0">
  <count-up ... :decimals="0" ... />
</template>
<template v-else>
  <count-up ... :decimals="2" ... />
</template>
archiewx commented 6 years ago

When the property changes, you didn't re-render it, which is really bad. My current solution is to randomly generate a key and let vue automatically re-render, which causes the performance of the page to drop.

archiewx commented 6 years ago

Thank you for your contribution. Thanks