返回组件清单中定义的 CSS、HTML 或 img 资源。
适用于
模型驱动应用
Syntax
context.resources.getResource(id, success, failure)
参数
| 参数名称 | 类型 | 必选 | Description |
|---|---|---|---|
| id | String |
是的 | 资源字符串标识符。 |
| success | function (string) => void |
否 | 成功回调。 资源数据以 base 64 编码格式返回。 |
| 失败 | function () => void |
否 | 失败回调。 |
Example
private setDefaultImage(): void {
this._context.resources.getResource(
DefaultImageFileName,
this.setImage.bind(this, false, "png"),
this.showError.bind(this)
);
this.controlContainer.classList.add(NoImageClassName);
// If it already has value, we need to update the output
if (this._context.parameters.value.raw) {
this._value = null;
this._notifyOutputChanged();
}
}