https://www.yuque.com/u2417328/rlt5do/kguiwo
vue 过滤器 数值过万处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <span>{{ num|million }}</span> <script> export default { filters:{ million: function (value) { let num; if (value > 9999) { num = Math.floor(value / 1000) / 10 + "W"; } else if (value < 9999 && value > -9999) { num = value; } else if (value < -9999) { num = -(Math.floor(Math.abs(value) / 1000) / 10) + "W"; } return num; }, },
}; </script>
|