码迷,mamicode.com
首页 > Web开发 > 详细

vue.js 实现购物车加减方法

时间:2017-06-08 22:35:45      阅读:419      评论:0      收藏:0      [点我收藏+]

标签:cout   --   min   rip   ret   put   app   eth   ace   

  1. <template>
  2. <div class="coutter-wrapper">
  3. <button type="button" @click="plus">+</button>
  4. <button type="button">{{ result }}</button>
  5. <button type="button" @click="minus">-</button>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. result: 0,
  13. }
  14. }
  15. methods: {
  16. minus() {
  17. this.result--;
  18. this.$emit(‘input‘, {res: this.result, other: ‘--‘})
  19. },
  20. plus() {
  21. this.result++;
  22. this.$emit(‘input‘, {res: this.result, other: ‘++‘})
  23. }
  24. }
  25. }
  26. </script>
  27. <style lang="stylus" scoped>
  28. button
  29. border 0
  30. outline 0
  31. border-radius 3px
  32. button:nth-child(2)
  33. width 200px
  34. </style>

vue.js 实现购物车加减方法

标签:cout   --   min   rip   ret   put   app   eth   ace   

原文地址:http://www.cnblogs.com/gerry/p/6964802.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!