其他分享
首页 > 其他分享> > Vue计算加减法和取小数点后两位

Vue计算加减法和取小数点后两位

作者:互联网

计算加法

  methods: {
            subscript(){
                    this.a = 30,
                    this.b = 30,
                    this.jieguo = parseInt(this.a) + parseInt(this.b)
                    //parseInt 取整
            },

计算减法

  methods: {
            subscript(){
                    this.a = 30,
                    this.b = 30,
                    this.jieguo = parseInt(this.a) - parseInt(this.b)
                    //parseInt 取整
            },

乘法改成 * 除法 /

取小数点后两位 toFixed(2)方法

  subscript(){
                    this.a = 30,
                    this.b = 30,
                    this.jieguo = Number ((this.a-this.b).toFixed(2))
            },

直接完工希望对你有所帮助,
欢迎大家进群进行技术性的探讨, 群号:954314851
在这里插入图片描述

标签:Vue,methods,jieguo,30,小数点,toFixed,parseInt,subscript,加减法
来源: https://blog.csdn.net/weixin_48193717/article/details/116998751