我正在尝试使用 NumeralJS 格式化来自数据库的一些数字。
主函数文件中的代码:
$(document).ready(function(){
numeral.register('locale', 'pt-br', {
delimiters: {
thousands: '',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal : function (number){
return number === 1 ? 'er' : 'ème';
},
currency: {
symbol: 'R$'
}
});
if ($('[type="date"]').prop('type') != 'date'){
$('[type="date"]').datepicker();
}
});
页面代码
numeral.locale('pt-br');
...
var percDiferenca = numeral(retorno.dados[i].percentedif).format('0,00');
var percValor = numeral(retorno.dados[i].percenteval).format('0.00');
它输出 11.166 和 213986,00。我想要的结果是 11,66 和 2139,86。先感谢您。