vue按钮响应
1.代码
<script setup lang="ts"> import { ref } from 'vue' defineProps<{ msg: string }>() const count = ref(11) //函数卸载script里 function handleClick() { // 处理按钮点击事件的逻辑 console.log("按钮被点击了!"); } </script> <template> <h1>{{ msg }}</h1> <div class="card"> <button type="button" @click="count++">count is {{ count }}</button> <p> Edit <code>components/HelloWorld.vue</code> to test HMR </p> </div> <p> Check out <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank" >create-vue</a >, the official Vue + Vite starter </p> <p> Install <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a> in your IDE for a better DX </p> <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p> <button type="button" @click="handleClick">My Button </button> </template> <style scoped> .read-the-docs { color: #888; } </style>
长风破浪会有时,直挂云帆济沧海!
可通过下方链接找到博主
https://www.cnblogs.com/judes/p/10875138.html