This article shares the specific code of Vue to implement a simple shopping cart case for your reference. The specific content is as follows Code: <template> <div> <div> <span>Mobile: </span> <span>Price</span> <input type="number" v-model.number="phonePrice"> <span> Quantity</span><input type="number" v-model.number="phoneCount"> <span>Subtotal: </span><span>{{phoneTotal}} yuan</span> </div> <div> <span>Computer: </span> <span>Price</span> <input type="number" v-model.number="computerPrice"> <span> Quantity</span><input type="number" v-model.number="computerCount"> <span>Subtotal: </span><span>{{computerTotal}} yuan</span> </div> <div> <span>Shipping fee: </span><input type="number" v-model.number="freight"><span>Yuan</span><br> <span>Total: {{total}} yuan</span> <p>Discount: {{discounts}} yuan</p> <p>Payable: {{allPrice}}</p> </div> </div> </template> <script> export default { data () { return { phonePrice: '', // price of a phone phoneCount: '', // number of phones computerPrice: '', // price of a computer computerCount: '', // number of computers frequency: '', // freight discounts: '' } }, computed: { phoneTotal() { return this.phonePrice * this.phoneCount }, computerTotal() { return this.computerPrice * this.computerCount }, //Total price 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> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Nginx builds rtmp live server implementation code
>>: Implementation of proxy_pass in nginx reverse proxy
Latest solution: -v /usr/share/zoneinfo/Asia/Shan...
tomcat is an open source web server. The web base...
When making a web page, you sometimes use a dividi...
Preface Since many friends say they don’t have Ma...
MySQL master-slave setup MySQL master-slave repli...
Table of contents 1. Install Docker 2. Install so...
Table of contents Requirement description: Requir...
Table of contents 1. Plugins 2. Interlude 3. Impl...
When I was helping someone adjust the code today,...
1. --cpu=<value> 1) Specify how much availa...
The three-dimensional column chart consists of th...
1. Upper and lower list tags: <dl>..</dl...
1. Write a backup script rem auther:www.yumi-info...
For some systems with large amounts of data, the ...
ERROR 1290 (HY000) : The MySQL server is running ...