spz-event
Listen to the given event, when the event is triggered, execute the target API.
布局
Layouts
跳转到“Layouts”Usage
跳转到“Usage”In the following code, the render
action of the spz-render#cart-count
will be triggered when the dj.addToCart
and dj.cartChange
events are triggered.
<spz-render layout="container" id="cart-count" manual>
<!-- ... -->
</spz-render>
<spz-event
target-id="cart-count"
target-api="render"
event-name="dj.addToCart;dj.cartChange;"
layout="logic"
></spz-event>
Attributes
跳转到“Attributes”event-name
跳转到“event-name”Specifies one or more names of the event that separates by a ;
. Such as event-name="dj.addToCart;dj.cartChange;"
.
target-id
跳转到“target-id”Specifies the id of the element that needs to call an API when the event is triggered.
target-api
跳转到“target-api”Specifies the API of the element that needs to call when the event is triggered. Its default value is render
.
observer-id
跳转到“observer-id”Specifies an element of observation that has been loaded to execute an API of the target element.
delay
跳转到“delay”Specifies a milliseconds that delays calling an API when the event is triggered. Its default value is 0
.
Actions
跳转到“Actions”unListen
跳转到“unListen”Remove the event that has been listened to.
Parameter | Description | Type | Required |
---|---|---|---|
eventName | Remove event listener | string | Yes |