Vue 計(jì)數(shù)器的實(shí)現(xiàn)
更新時(shí)間:2021年10月26日 14:46:48 作者:Silent丿丶黑羽
這篇文章主要介紹了Vue 計(jì)數(shù)器的實(shí)現(xiàn),主要利用HTML實(shí)現(xiàn)步驟現(xiàn)在頁面上簡單實(shí)現(xiàn)一個(gè)計(jì)數(shù)器,內(nèi)容簡單且詳細(xì),需要的朋友可以參考一下
1、計(jì)數(shù)器的實(shí)現(xiàn)
在頁面上簡單實(shí)現(xiàn)一個(gè)計(jì)數(shù)器:
<!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>當(dāng)前計(jì)數(shù)器:{{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、實(shí)現(xiàn)效果
最后實(shí)現(xiàn)的效果,看下面的gif圖:

到此這篇關(guān)于Vue 計(jì)數(shù)器的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Vue 計(jì)數(shù)器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue+element ui實(shí)現(xiàn)錨點(diǎn)定位
這篇文章主要為大家詳細(xì)介紹了vue+element ui實(shí)現(xiàn)錨點(diǎn)定位,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-06-06
vue中利用Promise封裝jsonp并調(diào)取數(shù)據(jù)
Promise就是一個(gè)給一步操作提供的容器,在這個(gè)容器里,有兩個(gè)階段無法改變的階段,這兩個(gè)階段在文中給大家提到。對vue中利用Promise封裝jsonp并調(diào)取數(shù)據(jù) 的相關(guān)知識感興趣的朋友,跟隨小編一起看看吧2019-06-06

