Vue實(shí)現(xiàn)簡(jiǎn)單的購(gòu)物車(chē)案例
更新時(shí)間:2021年10月04日 09:48:12 作者:Nero09xx
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)簡(jiǎn)單的購(gòu)物車(chē)案例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了Vue實(shí)現(xiàn)簡(jiǎn)單的購(gòu)物車(chē)案例的具體代碼,供大家參考,具體內(nèi)容如下
代碼:
<template> <div> <div> <span>手機(jī): </span> <span>價(jià)格</span> <input type="number" v-model.number="phonePrice"> <span> 數(shù)量 </span><input type="number" v-model.number="phoneCount"> <span> 小計(jì): </span><span>{{phoneTotal}}元</span> </div> <div> <span>電腦: </span> <span>價(jià)格</span> <input type="number" v-model.number="computerPrice"> <span> 數(shù)量 </span><input type="number" v-model.number="computerCount"> <span> 小計(jì): </span><span>{{computerTotal}}元</span> </div> <div> <span>運(yùn)費(fèi): </span><input type="number" v-model.number="freight"><span>元</span><br> <span>共計(jì): {{total}}元</span> <p>優(yōu)惠: {{discounts}}元</p> <p>應(yīng)付: {{allPrice}}</p> </div> </div> </template> <script> export default { data () { return { phonePrice: '', // 手機(jī)單價(jià) phoneCount: '', // 手機(jī)數(shù)量 computerPrice: '', // 電腦單價(jià) computerCount: '', // 電腦數(shù)量 freight: '', // 運(yùn)費(fèi) discounts: '' } }, computed: { phoneTotal () { return this.phonePrice * this.phoneCount }, computerTotal () { return this.computerPrice * this.computerCount }, // 總價(jià) total () { return this.computerTotal + this.phoneTotal + this.freight }, allPrice () { return this.total - this.discounts } }, watch: { total: { depp: true, handler () { if (this.phoneTotal + this.computerTotal > 5000 && this.phoneTotal + this.computerTotal < 8000) { this.discounts = 100 } else if (this.phoneTotal + this.computerTotal > 8000) { this.discounts = 200 } } } } } </script> <style scoped lang='less'> </style>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- vuejs手把手教你寫(xiě)一個(gè)完整的購(gòu)物車(chē)實(shí)例代碼
- 基于Vuejs實(shí)現(xiàn)購(gòu)物車(chē)功能
- Vue實(shí)現(xiàn)購(gòu)物車(chē)功能
- vue實(shí)現(xiàn)購(gòu)物車(chē)小案例
- vue實(shí)現(xiàn)商城購(gòu)物車(chē)功能
- vue 實(shí)現(xiàn)購(gòu)物車(chē)總價(jià)計(jì)算
- vuex實(shí)現(xiàn)的簡(jiǎn)單購(gòu)物車(chē)功能示例
- vue+vant-UI框架實(shí)現(xiàn)購(gòu)物車(chē)的復(fù)選框全選和反選功能
- vue實(shí)現(xiàn)購(gòu)物車(chē)拋物線(xiàn)小球動(dòng)畫(huà)效果的方法詳解
- Vue.js實(shí)現(xiàn)的購(gòu)物車(chē)功能詳解
相關(guān)文章
vue實(shí)現(xiàn)帶自動(dòng)吸附功能的懸浮球
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)帶自動(dòng)吸附功能的懸浮球,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04學(xué)習(xí)vue.js中class與style綁定
這篇文章主要和大家一起學(xué)習(xí)vue.js中class與style綁定操作,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12Vue使用Proxy監(jiān)聽(tīng)所有接口狀態(tài)的方法實(shí)現(xiàn)
這篇文章主要介紹了Vue使用Proxy監(jiān)聽(tīng)所有接口狀態(tài)的方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06vue 自動(dòng)生成swagger接口請(qǐng)求文件的方法
這篇文章主要介紹了vue 自動(dòng)生成swagger接口請(qǐng)求文件的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-01-01深入解析el-col-group強(qiáng)大且靈活的Element表格列組件
這篇文章主要為大家介紹了el-col-group強(qiáng)大且靈活的Element表格列組件深入解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04