Click events bound by vue Prevent bubble instances and vue bind bubble instances.

Source: Internet
Author: User

Click events bound by vue Prevent bubble instances and vue bind bubble instances.

When using vue for a project, we often use Click Event binding, but we are tied to a div with other buttons (such as deletion and modification) the button will also load the div click event here, but we don't need it. How to Solve it:

First, let's distinguish between event bubbling and event capture.

(1) bubble events: events are triggered in the order from the most specific event target to the least specific event Target (document Object.

Internet Explorer 6.0: div-> body-> html-> document

Mozilla 1.0: div-> body-> html-> document-> window

(2) event capturing: events are triggered starting from the most inaccurate object (document Object), and then to the most precise (events can also be captured at the window level, but it must be specified by developers ).

(3) DOM event stream: two types of event models are supported at the same time: capture-type events and bubble-type events. However, capture-type events occur first. The two event streams touch all the objects in the DOM, starting from the document Object and ending the document Object.

<Span style = "font-family: SimSun; font-size: 14px;"> <div class = "tableContent" v-for = "(items, index) in dataList "v-on: click =" changeBacks (items) ": class =" {tableContentHover: items. changeBack} "> <ul> <li> <span> <label: class =" {labelChange: items. changeBack} "> √ </label> </span> <label v-html =" items. name "> </label> </li> <label v-html =" items. sex "> </label> </li> <label v-html =" items. tel "> </label> </li> <label v-html =" items. age "v-if =" items. age <= 20 "v-bind: class =" 'black' "> </label> <label v-html =" items. age "v-else-if =" items. age <= 40 "v-bind: class =" 'green' "> </label> <label v-html =" items. age "v-else-if =" items. age <= 60 "v-bind: class =" 'blue' "> </label> <label v-html =" items. age "v-else-if =" items. age <= 80 "v-bind: class =" 'purple '"> </label> <label v-html =" items. age "v-else v-bind: class =" 'red' "> </label> </li> <label v-html =" items. sion "> </label> </li> <button v-on: click. stop = "deleteThis (index)"> Delete </button> </li> </ul> </div> </span>

At this timeButtonClick Event plus. StopTo solve the above problems.

The above click events bound to the vue block the bubble are all the content shared by Alibaba Cloud xiaobian. I hope you can provide a reference and support for the customer's home.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.