• 如何通过watch监听单选框动态的显示选中和取消选中时对应的金额?


    这是之前的一个需求:

     当全部选中时,退保金额为主险和附加险的总和

     当取消主险的时候只显示附险的退保金额

     当全部取消的时候,退保金额是0元

    思路:

    首先是对单选框的checked进行watch监听。

     代码:

    checked(val){
           if(this.checked){
                this.surrenderAmount = this.newAmount
            }else{
               this.surrenderAmount = (Number(this.surrenderAmount).toFixed(2)-Number(this.list[0].polPrem).toFixed(2)).toFixed(2)
            }
        }

    然后,对附加险选中和取消选中的时候:

     代码:

     checkItem(show, index) {
          if (show) {
            this.list[index].show = false
            this.surrenderAmount = (Number(this.surrenderAmount).toFixed(2) - Number(this.list[index].polPrem).toFixed(2)).toFixed(2)
          } else {
            this.list[index].show = true
            this.surrenderAmount += this.list[index].polPrem
          }
        }

    这样就能实现动态改变金额的效果了。

  • 相关阅读:
    JavaScript—— scroolleftoffsetleft 系列的含义以及浏览器兼容问题
    GCD
    Treap
    快速* 模板
    线性筛素数
    珂朵莉树
    One Night
    长整数相加运算(内含减法)。。= =
    骑士周游 非完美版。。= =
    《Windows取证分析》
  • 原文地址:https://www.cnblogs.com/Ky-Thompson23/p/13043486.html
Copyright © 2020-2023  润新知