Skip to content

@vtj / Modules / core / NodeModel

Class: NodeModel

core.NodeModel

节点模型

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new NodeModel(schema, parent?): NodeModel

Parameters

NameTypeDefault value
schemaNodeSchemaundefined
parentnull | NodeModelnull

Returns

NodeModel

Defined in

packages/core/src/models/node.ts:86

Properties

__VTJ_NODE__

Readonly __VTJ_NODE__: boolean = true

标记

Defined in

packages/core/src/models/node.ts:29


children

children: string | JSExpression | NodeModel[] = ''

子节点

Defined in

packages/core/src/models/node.ts:59


directives

directives: DirectiveModel[] = []

指令

Defined in

packages/core/src/models/node.ts:79


disposed

disposed: boolean = false

销毁标识

Defined in

packages/core/src/models/node.ts:84


events

events: Record<string, EventModel> = {}

节点事件

Defined in

packages/core/src/models/node.ts:74


from

Readonly from: NodeFrom

组件来源

Defined in

packages/core/src/models/node.ts:51


id

Readonly id: string

节点唯一标识

Defined in

packages/core/src/models/node.ts:43


invisible

invisible: boolean = false

是否不可见

Defined in

packages/core/src/models/node.ts:55


locked

locked: boolean = false

锁定

Defined in

packages/core/src/models/node.ts:34


name

Readonly name: string

名称,即组件的名称或html的标签名

Defined in

packages/core/src/models/node.ts:47


parent

parent: null | NodeModel = null

Defined in

packages/core/src/models/node.ts:86


props

props: Record<string, PropModel> = {}

节点属性

Defined in

packages/core/src/models/node.ts:69


slot

Optional slot: NodeSlot

放置在父组件的插槽

Defined in

packages/core/src/models/node.ts:64


nodes

Static nodes: Record<string, NodeModel> = {}

记录所有节点的实例

Defined in

packages/core/src/models/node.ts:39

Methods

appendChild

appendChild(node, silent?): void

追加子节点

Parameters

NameTypeDefault value
nodeNodeModelundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:285


dispose

dispose(silent?): void

销毁

Parameters

NameTypeDefault value
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:408


getPropValue

getPropValue(name): JSONValue | JSExpression | JSFunction

获取属性值

Parameters

NameType
namestring

Returns

JSONValue | JSExpression | JSFunction

Defined in

packages/core/src/models/node.ts:192


insertAfter

insertAfter(node, silent?): void

在当前节点的后面插入节点

Parameters

NameTypeDefault value
nodeNodeModelundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:305


insertBefore

insertBefore(node, silent?): void

在当前节点的前面插入节点

Parameters

NameTypeDefault value
nodeNodeModelundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:324


isChild

isChild(node): boolean

Parameters

NameType
nodeNodeModel

Returns

boolean

Defined in

packages/core/src/models/node.ts:464


lock

lock(silent?): void

Parameters

NameTypeDefault value
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:428


moveNext

moveNext(silent?): void

Parameters

NameTypeDefault value
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:352


movePrev

movePrev(silent?): void

Parameters

NameTypeDefault value
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:337


removeChild

removeChild(node, silent?): void

删除子节点

Parameters

NameTypeDefault value
nodeNodeModelundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:267


removeDirective

removeDirective(dirctive, silent?): void

删除指令

Parameters

NameTypeDefault value
dirctiveDirectiveModelundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:249


removeEvent

removeEvent(name, silent?): void

删除事件

Parameters

NameTypeDefault value
namestringundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:220


removeProp

removeProp(name, silent?): void

删除属性

Parameters

NameTypeDefault value
namestringundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:180


setChildren

setChildren(children?, silent?): void

设置子节点

Parameters

NameTypeDefault value
childrenstring | JSExpression | NodeSchema[]''
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:125


setDirective

setDirective(scheam, silent?): void

新增或更新指令

Parameters

NameTypeDefault value
scheamNodeDirectiveundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:232


setEvent

setEvent(scheam, silent?): void

新增或更新事件

Parameters

NameTypeDefault value
scheamNodeEventundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:203


setProp

setProp(name, value, defaultValue?, silent?): void

新增或更新属性

Parameters

NameTypeDefault value
namestringundefined
valueJSONValue | JSExpression | JSFunctionundefined
defaultValue?JSONValue | JSExpression | JSFunctionundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:158


setSlot

setSlot(slot?, silent?): void

设置节点放置的插槽

Parameters

NameTypeDefault value
slot?string | NodeSlotundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:144


setVisible

setVisible(visible, silent?): void

Parameters

NameTypeDefault value
visiblebooleanundefined
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:452


toDsl

toDsl(): NodeSchema

获取DSL

Returns

NodeSchema

Defined in

packages/core/src/models/node.ts:372


unlock

unlock(silent?): void

Parameters

NameTypeDefault value
silentbooleanfalse

Returns

void

Defined in

packages/core/src/models/node.ts:440


update

update(schema, silent?): void

更新节点属性

Parameters

NameTypeDefault valueDescription
schemaPartial<NodeSchema>undefined
silentbooleanfalse是否静默,静默更新即不触发事件

Returns

void

Defined in

packages/core/src/models/node.ts:99

Released under the MIT License.