把分转为元 保留2位小数
toPrice(x) {
if (x !== null) {
let xx: any = x / 100;
let f: any = Math.round(xx * 100) / 100;
let s: any = f.toString();
let rs: any = s.indexOf('.');
if (rs < 0) {
rs = s.length;
s += '.';
}
while (s.length <= rs + 2) {
s += '0';
}
return s;
}
return x;
}
网友评论