010.Vue3入门,事件传参的用法
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、效果如下: