// 数字转"万" 过滤器
Vue.filter('numberTextFormat', (value) => {
if(value !== undefined && value !== null) {
if(Number(value) < 10000) {
let str = value.toString();
let reg = str.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
return str.replace(reg, '$1,');
} else {
let str = Number((Number(value) / 10000).toFixed(2)).toString();
let reg = str.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
return str.replace(reg, '$1,');
}
}else{
return '';
}
});
javascript:数字转“万“ 过滤器
最新推荐文章于 2024-04-30 10:10:52 发布