Skip to content

changeAttr ​

修改元素属性(静态方法),一般用来修改默认值

关键属性 ​

changeAttr ( attrName: string, defaultValue: IValue ) ​

修改元素属性的默认值 (全局操作)。

示例 ​

修改文本默认填充色为红色 ​

后续创建的所有文本,默认填充色都将变为红色, 但不会影响其他类型的元素。

ts
import { Leafer, Text } from 'leafer-ui'

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

Text.changeAttr('fill', 'red')  

const text = new Text({ text: 'Welcome to LeaferJS' })

leafer.add(text)

Released under the MIT License.