Differences of E.Target and E.CurrentTarget in WeChat applet event object

When a small program’s event callback trigger, an event object is received, and the parameter of the event object contains a Target and CurrentTarget attribute, and then tell the difference between the two.

WXML section:

Parent component
# TAR-Father {Width: 300rpx; Height: 300rpx; Background-Color: SkyBlue;} #} #}

JS section:

Click: function (event) {console.log (event.target) Console.log (event.currenttarget)}


When clicked on the output of the pink sub-assembly area:

Event.target is a sub-assembly, That is to trigger the source component
 Event.currentTarget is a component   that is bound to the event 
when clicking the output of the blue parent component area in the picture:

Event.target is a parent component because the source of trigger is alsoIt is the parent component itself

微信小程序事件对象中e.target和e.currentTarget的区别详解 Event.currentTarget Summary for the component

bonded to the event: Target corresponds to the source components of the trigger event, which may be a sub-component, It is possible to be a parent component, mainly to see an area where the action is performed. The CurrentTarget always corresponds to the components bound to the event.

The above is all the content of this article, I hope to help everyone, I hope everyone will support Tumi Cloud.

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment