Home > Article > Web Front-end > How to prevent click events from bubbling in vue
Below I will share with you a method to prevent click events from bubbling and triggering another event in Vue. It has a good reference value and I hope it will be helpful to everyone.
Use vue to prevent the click event of child elements from bubbling up. It is very simple. Use stop
<p @click="test1()"> <span @click.stop="test2()">按钮1</span> <span>按钮2</span> </p>
so that when you click button 1 in p, the p binding time test1() method will not be triggered. .
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
JavaScript operating principle
Select all and invert selection in vue
Detailed explanation of using jest to test react native components
The above is the detailed content of How to prevent click events from bubbling in vue. For more information, please follow other related articles on the PHP Chinese website!