Skip to content
导航

Group ​

创建组,默认宽高随子元素自动变化。

关键属性 ​

children: UI[] ​

子元素。

关键方法 ​

add(child: UI) ​

添加子元素。

addAt(child: UI, index: number) ​

在指定位置添加子元素。

addBefore(child: UI, before: UI) ​

在指定元素前面添加子元素。

addAfter(child: UI, after: UI) ​

在指定元素后面添加子元素。

remove(child?: UI): void ​

移除指定的子元素。

当 child 参数不存在时,移除当前元素。

示例 ​

ts
import { Leafer, Group, Rect, Ellipse } from 'leafer-ui'

const leafer = new Leafer({ view: window })

const group = new Group({ 
    x: 100,
    y: 100
})

const rect = new Rect({
    width: 200,
    height: 200,
    fill: '#32cd79',
    draggable: true
})

const ellipse = new Ellipse({
    x: 50,
    y: 50,
    width: 100,
    height: 100,
    innerRadius: 0.5,
    fill: "white"
})

leafer.add(group)
group.add(rect)
group.add(ellipse)

继承 ​

UI ​

API ​

Group ​

Released under the MIT License.