工作生活

简单实用计算属性,算乘除

2019-07-01  本文已影响0人  考拉_2044

```js

        // 计算属性使用方法

        //下需要用到的地方直接调用,在computer中返回计算结果

          computed: {

                computerNumer: function () {

                    const  self = this;

                    if(self.curArithmetic == '乘') {

                        let res = self.exr * self.curMoney

                        return  vm.paymentVoList[curIndex].convertTotal  = res.toFixed(2);

                    }

                    if(self.curArithmetic == '除') {

                        let res = self.curMoney / self.exr;

                        return  vm.paymentVoList[curIndex].convertTotal  = res.toFixed(2);

                    }

                }

            },

          calculateDiscount: function(e,arithmetic,money,index) {

                    const self = this;

                      self.exr  = e.target.value;

                      self.curArithmetic = arithmetic;

                      self.curMoney  = money;

                      curIndex = index;

                      vm.computerNumer;

                },

```

上一篇 下一篇

猜你喜欢

热点阅读