vue问题六:计算属性,依赖发生变化时,重新计算computed:

<el-form-item label="单价:"  prop="price" >
       <el-input v-model="addform.price" type="number" placeholder="请输入单价" auto-complete="off" class="widc" >el-input>
 el-form-item>
<el-form-item label="数量:"  prop="number" >
       <el-input v-model="addform.number" type="number" placeholder="请输入数量" auto-complete="off" class="widc" >el-input>
el-form-item>
<el-form-item label="总金额:"  prop="sum" >
       <div v-model="addform.countNum" class="border" ><span style="margin-left: 10%">{{countNum}}span>div>
el-form-item>
vue html代码
// 计算总金额
    computed:{
      countNum:function(addform){
        let countNum=Number(this.addform.price) * Number(this.addform.number)
        return countNum
      }
    },
vue JavaScript代码

 

转载于:https://www.cnblogs.com/M-miao/p/9838737.html

你可能感兴趣的:(vue问题六:计算属性,依赖发生变化时,重新计算computed:)