ChildEvent
Child 事件, leafer.ready
事件之后才会派发此事件。
想了解事件的用途,请查看 渲染生命周期 图示。
事件名称
ChildEvent.ADD
添加对象
child.add
ChildEvent.REMOVE
删除对象
child.remove
关键属性
child: ILeaf
子对象
parent: ILeaf
父对象
示例
ts
import { Leafer, Group, Rect, ChildEvent, LeaferEvent } from 'leafer-ui'
const leafer = new Leafer({ view: window })
const group = new Group()
leafer.add(group)
function onReady() {
leafer.on(ChildEvent.ADD, function (e: ChildEvent) {
console.log('leafer', e.parent, e.child)
})
group.on(ChildEvent.ADD, function (e: ChildEvent) {
console.log('group', e.parent, e.child)
})
const rect = new Rect({ x: 100, y: 100, fill: '#32cd79', draggable: true })
group.add(rect)
}
leafer.on(LeaferEvent.READY, onReady)