點擊按鈕讓數字+1
template結構
<template> <div class="shiyan"> <div class="shiyan1"> <p>{{count}}</p> <button @click="add">+1</button> </div> </div> </template>
script結構
<script>
export default {
data() {
return {
count: 0
};
},
methods: {
add() {
this.count++
}
}
};
</script>
style結構
<style lang="scss"> @import "../index.scss"; .shiyan { width: 100%; height: 100%; .shiyan1 { width: 500px; height: 500px; margin: 35px auto; background-color: #eae8e8; } } </style>
點擊按鈕讓數字+1效果圖

