Click event If you can’t get an event if you have @click=”foo()” in your HTML, you either have to unbracket the event, or

 @click="foo($event)"
Copy the code
<! DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, User-scalable =no"> <meta name="author" content=" title "> </title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <style> </style> </head> <body> <div id="app"> <button @click="foo()">fuck</button> </div> <script src="https://unpkg.com/vue@next"></script> <script> const app = Vue.createApp({ data() { return{ name:123 } }, methods: { foo(ev){ console.log(ev) } }, }) app.mount('#app') </script> </body> </html>Copy the code