收藏
回答

保留2位小数?

bindAddm3:function(e) {

    var rm3 =(this.data.numg1 * 1 / ((this.data.numg1 * 1 / this.data.numd1 * 1 + this.data.numg2 * 1 / this.data.numd2 * 1 + this.data.numg3 * 1  / this.data.numd3 * 1/ 3 *2 - 1));

    console.log(rm3);

    this.setData({

      resultm3: rm3

    })


回答关注问题邀请回答
收藏

3 个回答

  • ⅴ
    2022-10-26

    四舍五入:

    num = num.toFixed(2)
    


    不四舍五入,直接截取:

    Math.floor(15.7784514000 * 100) / 100 
    


    2022-10-26
    有用
    回复
  • 拾柒
    拾柒
    2022-10-26

    console.log(rm3.toFixed(2))

    2022-10-26
    有用
    回复
  • 葫芦爷救娃娃
    葫芦爷救娃娃
    2022-10-26

    直接用 toFixed 方法不可以吗

    2022-10-26
    有用
    回复
登录 后发表内容