@vtj / Modules / core / NodeModel
Class: NodeModel
core.NodeModel
节点模型
Table of contents
Constructors
Properties
Methods
- appendChild
- dispose
- getPropValue
- insertAfter
- insertBefore
- isChild
- lock
- moveNext
- movePrev
- removeChild
- removeDirective
- removeEvent
- removeProp
- setChildren
- setDirective
- setEvent
- setProp
- setSlot
- setVisible
- toDsl
- unlock
- update
Constructors
constructor
• new NodeModel(schema
, parent?
): NodeModel
Parameters
Name | Type | Default value |
---|---|---|
schema | NodeSchema | undefined |
parent | null | NodeModel | null |
Returns
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
Name | Type | Default value |
---|---|---|
node | NodeModel | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:285
dispose
▸ dispose(silent?
): void
销毁
Parameters
Name | Type | Default value |
---|---|---|
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:408
getPropValue
▸ getPropValue(name
): JSONValue
| JSExpression
| JSFunction
获取属性值
Parameters
Name | Type |
---|---|
name | string |
Returns
JSONValue
| JSExpression
| JSFunction
Defined in
packages/core/src/models/node.ts:192
insertAfter
▸ insertAfter(node
, silent?
): void
在当前节点的后面插入节点
Parameters
Name | Type | Default value |
---|---|---|
node | NodeModel | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:305
insertBefore
▸ insertBefore(node
, silent?
): void
在当前节点的前面插入节点
Parameters
Name | Type | Default value |
---|---|---|
node | NodeModel | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:324
isChild
▸ isChild(node
): boolean
Parameters
Name | Type |
---|---|
node | NodeModel |
Returns
boolean
Defined in
packages/core/src/models/node.ts:464
lock
▸ lock(silent?
): void
Parameters
Name | Type | Default value |
---|---|---|
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:428
moveNext
▸ moveNext(silent?
): void
Parameters
Name | Type | Default value |
---|---|---|
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:352
movePrev
▸ movePrev(silent?
): void
Parameters
Name | Type | Default value |
---|---|---|
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:337
removeChild
▸ removeChild(node
, silent?
): void
删除子节点
Parameters
Name | Type | Default value |
---|---|---|
node | NodeModel | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:267
removeDirective
▸ removeDirective(dirctive
, silent?
): void
删除指令
Parameters
Name | Type | Default value |
---|---|---|
dirctive | DirectiveModel | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:249
removeEvent
▸ removeEvent(name
, silent?
): void
删除事件
Parameters
Name | Type | Default value |
---|---|---|
name | string | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:220
removeProp
▸ removeProp(name
, silent?
): void
删除属性
Parameters
Name | Type | Default value |
---|---|---|
name | string | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:180
setChildren
▸ setChildren(children?
, silent?
): void
设置子节点
Parameters
Name | Type | Default value |
---|---|---|
children | string | JSExpression | NodeSchema [] | '' |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:125
setDirective
▸ setDirective(scheam
, silent?
): void
新增或更新指令
Parameters
Name | Type | Default value |
---|---|---|
scheam | NodeDirective | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:232
setEvent
▸ setEvent(scheam
, silent?
): void
新增或更新事件
Parameters
Name | Type | Default value |
---|---|---|
scheam | NodeEvent | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:203
setProp
▸ setProp(name
, value
, defaultValue?
, silent?
): void
新增或更新属性
Parameters
Name | Type | Default value |
---|---|---|
name | string | undefined |
value | JSONValue | JSExpression | JSFunction | undefined |
defaultValue? | JSONValue | JSExpression | JSFunction | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:158
setSlot
▸ setSlot(slot?
, silent?
): void
设置节点放置的插槽
Parameters
Name | Type | Default value |
---|---|---|
slot? | string | NodeSlot | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:144
setVisible
▸ setVisible(visible
, silent?
): void
Parameters
Name | Type | Default value |
---|---|---|
visible | boolean | undefined |
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:452
toDsl
▸ toDsl(): NodeSchema
获取DSL
Returns
Defined in
packages/core/src/models/node.ts:372
unlock
▸ unlock(silent?
): void
Parameters
Name | Type | Default value |
---|---|---|
silent | boolean | false |
Returns
void
Defined in
packages/core/src/models/node.ts:440
update
▸ update(schema
, silent?
): void
更新节点属性
Parameters
Name | Type | Default value | Description |
---|---|---|---|
schema | Partial <NodeSchema > | undefined | |
silent | boolean | false | 是否静默,静默更新即不触发事件 |
Returns
void
Defined in
packages/core/src/models/node.ts:99