vue中处理数字加逗号

<div>
	<span class="num purple">{{productInfo.balance | formatnum}}span>
	<span class="unit purple">span>
div>
filters: {
    formatnum(num) {
        var result = '', counter = 0;
        num = Number((num || 0)).toString();
        for (var i = num.length - 1; i >= 0; i--) {
            counter++;
            result = num.charAt(i) + result;
            if (!(counter % 3) && i != 0) { result = ',' + result; }
        }
        return result;
    }
},

vue中处理数字加逗号_第1张图片

你可能感兴趣的:(vue,JavaScript,笔记,vue.js,javascript,前端)