Home  >  Article  >  Web Front-end  >  How to prevent click events from bubbling in vue

How to prevent click events from bubbling in vue

亚连
亚连Original
2018-06-07 11:12:104549browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn