Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k 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 OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[1] html - How to create even cell spacing within a

2.1m questions

2.1m answers

60 comments

57.0k users

...