stopPropagation

uniapp uni-icons @click.stop 报Cannot read properties of undefined (reading 'stopPropagation')

点进去看了一下uni-icons的源码 @click的方法其实是他假装是个原生click的方法,执行 emit(click)给父组件 可以理解为uni-icons只至此click事件 不支持click.stop事件 解决办法也很简单 包一层view <view @click.stop="editFn ......

e.preventDefault() 是用来阻止默认事件的,不是阻止事件冒泡 ;事件冒泡应该是 e.stopPropagation()

假设DOM结构为: JS代码为: document.getElementById('a').addEventListener('click', e => {console.log(1)}); document.getElementById('b').addEventListener('click', ......
事件 stopPropagation preventDefault
共2篇  :1/1页 首页上一页1下一页尾页