Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
910 views
in Technique[技术] by (71.8m points)

js小数点保留两位小数

为什么我这样只保留一位小数如97.6 ...

filters: {
    memberPic(val) {
        let pic = val * (that.discount  / 10)
        var f = parseFloat(pic);
        if (isNaN(f)) {
            return;
        }
        f = Math.round(pic * 100) / 100;
        return f;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

返回结果改一下

  return f.toFixed(2);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...