用于初始化组件实例。 组件可以启动远程服务器调用和其他初始化作。 无法在此处初始化数据集值,请使用 updateView 方法实现此目的。
应调用 trackContainerResize 一次,最好在组件init方法中通知组件需要布局信息。 使用此方法告知框架填充 allocatedHeight 和 allocatedWidth 方法。
注释
应在 and allocatedWidth 方法之前allocatedHeight先调用 tractContainerResize。
适用于
模型驱动应用、画布应用和门户。
Syntax
init(context,notifyOutputChanged,state,container)
参数
| 参数名称 | 类型 | 必选 | Description |
|---|---|---|---|
| 上下文 | 上下文 | 是的 | 包含参数、组件元数据和接口函数的 输入属性 。 |
| notifyOutputChanged | function |
否 | 通知框架有新输出的方法 |
| 状态 | Dictionary |
否 | 在上一个会话中从 setControlState 保存的组件状态 |
| 容器 | HTMLDivElement | 否 | 要呈现的 div 元素 |
Example
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
{
this._labelElement = document.createElement("label");
this._labelElement.setAttribute("class", "HelloWorldColor");
container.appendChild(this._labelElement);
}