計數器簡易圖?<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>當前計數:{{counter}}</h2>
<!-- <button v-on:click="counter "> </button> -->
<!-- <button v-on:click="counter--">-</button> -->
<button v-on:click="add"> </button>
<button @click="sub">-</button>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
counter: 0
},
methods: {
add: function () {
console.log("add被執行");
this.counter ;
},
sub: function () {
console.log("sub被執行");
this.counter--;
}
}
})
</script>
</body>
</html>
,我來為大家講解一下關于計數器簡易圖?跟着小編一起來看一看吧!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>當前計數:{{counter}}</h2>
<!-- <button v-on:click="counter "> </button> -->
<!-- <button v-on:click="counter--">-</button> -->
<button v-on:click="add"> </button>
<button @click="sub">-</button>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
counter: 0
},
methods: {
add: function () {
console.log("add被執行");
this.counter ;
},
sub: function () {
console.log("sub被執行");
this.counter--;
}
}
})
</script>
</body>
</html>
更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!