共用方式為


get資源

傳回元件資訊清單中定義的 CSS、HTML 或 img 資源。

適用於

模型導向應用程式

語法

context.resources.getResource(id, success, failure)

參數

參數名稱 類型 為必填項目 Description
識別碼 String Yes 資源字串識別碼。
function (string) => void 成功回呼。 資源資料會以基底 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();
    }
  }

資源
Power Apps 元件架構 API 參考
Power Apps 元件架構概觀