封装函数: function numFormat(num) { if (num >= 10000) { num = Math.round(num / 1000) / 10 + 'w' } else if (num >= 1000) { num = Math.round(num / 100) / 10 + 'k' } return num } console.log(numFormat(9527)) // 输出:9.5k console.log(numFormat(16570)) // 输出:1.7w