How to make the color of 0000 retained after the decimal is different from the non-zero number?

lastZero:function (num) {
    var reg = /0+$/;
    return reg.test(num)
  }

I wrote a rule, but I still think that the rule is just to determine whether the last number is 0

.

what I want is some data returned in the background. If the end of these numbers is 0, I will make the colors of these 000s different, like

below.

excuse me, how should this effect be achieved, whether it is in vue, is it possible to do it with a filter or other js code?

can you provide a sample code?


vue has not been used, but you can probably use 000 to deal with

.
function splitNum(numStr){
    var regex=/^(?=.*\.)([\d.]*?)(0+)$/;
    var result=numStr.match(regex);
    return result?(result[1]+","+result[2]):numStr;
}
function lastZero(numStr){
    var regex=/[^0](?=0+$)/;
    return numStr.indexOf(".")>=0?numStr.replace(regex,"$&,"):numStr;
}

regular can take out two parts of data at the same time


let str = "123.320000" ;

Number(str) //
// 123.32

str.length - String(Number(str)).length 0
//4

forgive me for forgetting the regular pattern.

Menu