阅读 121

vue3 click细节无法获取event

点击事件 如果在html里写的是 @click="foo()" 获取不到event事件, 要么把事件的括号去掉,要么

 @click="foo($event)"
复制代码

<!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>
复制代码
文章分类
前端
文章标签