Vue Listener list Item render event

Source: Internet
Author: User

Straight to the point, no nonsense.

Using the Vue render list is very simple and convenient, but if you need to be in the rendering of the item to listen to the event can not be achieved, I have searched the Vue API did not find the appropriate way to solve, which also mentioned the use of Watch and vue.nextclick monitoring, but these can not be achieved, Distress Ah, but the wit I still think of the curve saved method, using the filter to implement, the code is as follows

<li v-for= "Item in List" > {item.content | setevent  item.id, item.name}}</li>
new Vue ({
       el: ",
       data:{
           list:[]
      },
       fliters:{
            setevent:function (content, ID, name) {
                 //TODO handle your event .... return
                content;          
            }
       }
)
Filter functions always take the value of an expression as the first argument (item.content). Quoted parameters are treated as strings, and arguments without quotes are evaluated by expression. Here the expression item.id is passed to the filter as the second argument, and the value of the expression Item.name is computed as the third argument. Be sure to return the current Li need to display the content, otherwise li no data display, so that you can monitor the list item of the rendering event, powerful not. Ha ha.

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.