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

How to prevent click events from bubbling in vue

亚连
Release: 2018-06-07 11:12:10
Original
4591 people have browsed it

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>
Copy after login

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!

Related labels:
vue
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template