关于#vue.js#的问题

例如120 现在是120.0000000001 只需要保留一位小数

        this.$nextTick(() => {
          this.totalPrice = 0
          this.carData.forEach((shop) => {
            shop.things.forEach((good) => {
              if (good.goodCheck) {
                this.totalPrice+= good.price * good.tNum
              }
            })
          })
        })
      },

函数toFixed()保留几位小数就填几,会自动四舍五入

this.$nextTick(() => {
          this.totalPrice = 0
          this.carData.forEach((shop) => {
            shop.things.forEach((good) => {
              if (good.goodCheck) {
                this.totalPrice+= good.price * good.tNum
              }
            })
          })
          this.totalPrice = this.totalPrice.toFixed(1);
        })
      },

最后 this.totalPrice = this.totalPrice.toFix(1)