选项式API_事件处理
bash
<template>
<h3>选项式API</h3>
<p>{{ count }}</p>
<button @click="addCountHandle">增加</button>
</template>
<script>
export default {
data(){
return{
count:0
}
},
methods:{
addCountHandle(){
this.count++
}
}
}
</script>
组合式API_事件处理
bash
<template>
<h3>组合式API</h3>
<p>{{ count }}</p>
<button @click="addCountHandle">增加</button>
</template>
<script setup>
import { ref } from "vue"
const count = ref(0)
function addCountHandle(){
count.value++
}
</script>