1、程式碼如下
<template> <h3>事件傳參</h3> <p @click="getNameHandler(item,$event)" v-for="(item,index) of names" :key="index">{{ item }}</p> </template> <script> export default { data() { return { names: ["張三", "李四", "王五"] } }, methods: { getNameHandler(name, e) { console.log(name); console.log(e); } } } </script>
2、效果如下: