zoukankan      html  css  js  c++  java
  • 如何通过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
          }
        }

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

  • 相关阅读:
    Redis内存回收策略
    7、IMS
    6、端局、汇接局、关口局、长途局
    5、IMS网元
    4、IMS
    3、NAT
    2、SIP
    1、B2BUA
    九、数据库——sql server 2008导入excel
    六十三、android pad
  • 原文地址:https://www.cnblogs.com/Ky-Thompson23/p/13043486.html
Copyright © 2011-2022 走看看