//单个数据千分位转字符串
function SingleDelete(num){
    if(num&&num!=undefined&&num!=null){
        let _num=num
        _num=_num.toString()
        _num=_num.replace(/,/gi,'')
        return _num
    }else{
        return _num
    }
}
//数组对象千分位转数据
function ManyObjDelete(num){
    if(num&&num!=undefined&&num!=null){
        let arrs=[]
        for (let i = 0; i < num.length; i++) {
            let _num = num[i].value;
            let _id=num[i]._id
            _num=_num.toString()
            _num=_num.replace(/,/gi,'')
            arrs.push({ value: _num, _id: _id})
        }
        return arrs
    }else{
        return num
    }
}
//数组千分位转数据
function ManyArrayDelete(num){
    if(num&&num!=undefined&&num!=null){
        let arrs=[]
        for (let i = 0; i < num.length; i++) {
            let _num = num[i];
            _num=_num.toString()
            _num=_num.replace(/,/gi,'')
            arrs.push(_num)
        }
        return arrs
    }else{
        return num
    }
}

 数据转千分位

// js数据加千分位
function numFormat(num){
    var res =num.toString().replace(/\d+/,function(n){
        return n.replace(/(\d)(?=(\d{3})+$)/g,function($1){
            return $1+','
        })
    })
    return res;
}

 

posted on 2021-05-24 13:30  小菟同学  阅读(92)  评论(0编辑  收藏  举报

……