我是靠谱客的博主 会撒娇大门,这篇文章主要介绍Vue 计数器的实现,现在分享给大家,希望可以做个参考。

1、计数器的实现

在页面上简单实现一个计数器:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../js/vue.js"></script> </head> <body> <div id="app"> <h3>当前计数器:{{counter}}</h3> <button @click="add">+</button> <button @click="minutes">-</button> </div> <script> const app = new Vue({ el: "#app", data: { counter: 0 }, methods: { add: function () { this.counter++; }, minutes: function () { this.counter--; } } }) </script> </body> </html>

2、实现效果

最后实现的效果,看下面的gif图:

到此这篇关于Vue 计数器的实现的文章就介绍到这了,更多相关Vue 计数器内容请搜索靠谱客以前的文章或继续浏览下面的相关文章希望大家以后多多支持靠谱客!

最后

以上就是会撒娇大门最近收集整理的关于Vue 计数器的实现的全部内容,更多相关Vue内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(118)

评论列表共有 0 条评论

立即
投稿
返回
顶部