Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

Vue中事件处理程序中如何获取绑定事件中的this(就是触发事件本身)

想要在vue中用@绑定的事件函数中获取绑定事件的元素

大概代码如下

<li class="item" @click="changeTab"></li>
<li class="item" @click="changeTab"></li>
<li class="item" @click="changeTab"></li>

methods: {
  changeTab: function() {
    // 我应该如何在这里获取触发事件的li元素呢,因为this绑定了Vue对象
  }
}

望大神帮忙解答


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@click='doSome(arg1,arg2,$event)'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...