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
This article uses an example to share with you a ...
Why is it stuck? There is a premise that must be ...
I encountered a problem today: Can I use the as a...
Spring integration with springmvc The web.xml con...
This article example shares the specific code of ...
1. Create a runner container mk@mk-pc:~/Desktop$ ...
1. Install the dependency packages first to avoid...
Preface: In project development, some business ta...
Table of contents Common functions of linux drive...
The Docker container provides services and listen...
This article shares with you a draggable photo wa...
Disclaimer: This password reset method can direct...
vue-cli uses stimulsoft.reports.js (nanny-level t...
Preface ActiveMQ is the most popular and powerful...
Introduction to vi/vim They are both multi-mode e...