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代碼
相關文章
相關標籤/搜索