Skip to content
导航

App

负责组织多个 Leafer 实例协同工作。

关键属性

isApp: boolean

是否为 App 实例对象, 默认为 true。

children: Leafer[]

Leafer 实例的子对象。

关键方法

addLeafer(config?:ILeaferConfig)

ts
import { App, Rect } from 'leafer-ui'

const app = new App({ view: window, type: 'user' }) 

const backgroundLayer = app.addLeafer()
const contentLayer = app.addLeafer({ type: 'design' })
const wireframeLayer = app.addLeafer()

const background = new Rect({ width: 800, height: 600, fill: 'gray' })
const rect = new Rect({ x: 100, y: 100, fill: '#32cd79', draggable: true })
const border = new Rect({ x: 200, y: 200, stroke: 'blue', draggable: true })

backgroundLayer.add(background)
contentLayer.add(rect)
wireframeLayer.add(border)

add(leafer: Leafer)

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

const app = new App({ view: window, type: 'user' }) 

const backgroundLayer = new Leafer()
const contentLayer = new Leafer({ type: 'design' })
const wireframeLayer = new Leafer()

app.add(backgroundLayer)
app.add(contentLayer)
app.add(wireframeLayer)

const background = new Rect({ width: 800, height: 600, fill: 'gray' })
const rect = new Rect({ x: 100, y: 100, fill: '#32cd79', draggable: true })
const border = new Rect({ x: 200, y: 200, stroke: 'blue', draggable: true })

backgroundLayer.add(background)
contentLayer.add(rect)
wireframeLayer.add(border)

继承

Leafer

API

App

Released under the MIT License.