我是靠谱客的博主 高高盼望,这篇文章主要介绍js click事件 addEventListener 传参(event),现在分享给大家,希望可以做个参考。

就算是传参数在也不用在绑定事件的时候写(event)

注意这里是在vue中写的 所以有一个this指向问题 在箭头函数里 this指向的是document 这里赋值给that

在解绑的时候也不要写(event)  第三个参数是控制是否冒泡的

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
clickevent(event) { //const playbox = document.getElementsByClassName("PlayBox")[0]; //const boxindex = event.path.findIndex((item) => item == playbox);//这里用到了event //if (boxindex == -1) { //this.islistAndlyric = false; document.removeEventListener("click", this.clickevent, true); //} }, listAndlyric() { //this.islistAndlyric = !this.islistAndlyric; const that = this; //if (this.islistAndlyric) { //this.$nextTick(() => { document.addEventListener("click", that.clickevent, true); //}); //} //},

最后

以上就是高高盼望最近收集整理的关于js click事件 addEventListener 传参(event)的全部内容,更多相关js内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部