Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以格式化从脏中获取的数据?例如,将 83647 格式化为 83,647。对于未格式化的数据,我有以下代码:
db.on('load', function() { db.set('john', {completed: '83647'}); console.log('John's completed tasks are: %s', db.get('john').completed); });
Numeral.js是您正在寻找的东西..
例子:
numeral(12345).format('0,0'); // -> 12,345