event//js部分showEvent(event){ //获取自定义data-id console.log(event.target.dataset.i..._vue中怎么使用event对象">
当前位置:   article > 正文

vue事件中如何使用event对象?_vue中怎么使用event对象

vue中怎么使用event对象

注意在事件中要使用 $ 符号

  1. //html部分
  2. <a href="javascript:void(0);" data-id="12" @click="showEvent($event)">event</a>
  3. //js部分
  4. showEvent(event){
  5. //获取自定义data-id
  6. console.log(event.target.dataset.id)
  7. //阻止事件冒泡
  8. event.stopPropagation();
  9. //阻止默认
  10. event.preventDefault()
  11. }

 

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读