vuejs点击获取当前元素内容

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/woshidamimi0/article/details/83445571

有时候要获取所点击元素的内容文本等信息

可以在点击事件里面加上$event,这样即可获取。注意,一定是$event,不然无效

 <div  @click="btn_user($event)">用户</div>

methods: {
   btn_user (e) {
        console.log(e.target.innerHTML)
     }
   }

猜你喜欢

转载自blog.csdn.net/woshidamimi0/article/details/83445571
今日推荐