共用方式為


控制流程標籤

注意

自 2022 年 10 月 12 日起,Power Apps 入口網站為 Power Pages。 其他資訊:Microsoft Power Pages 現在已推出 (部落格)
我們很快就會遷移並將 Power Apps 入口網站文件與 Power Pages 文件併合。

控制流程標籤決定哪一個程式碼區塊應執行,以及要轉譯的內容,根據指定的條件。 條件是使用可用的 Liquid 運算子所建置,或只是根據指定值為 true 或 false 來建立。

if

如果符合指定條件,則執行程式碼區塊。

{% if user.fullname == 'Dave Bowman' %}

Hello, Dave.

{% endif %}

unless

就像 if,但它是在符合指定條件時執行程式碼區塊。

{% unless page.title == 'Home' %}

This is not the Home page.

{% endunless %}

elsif/else

新增其他條件至 if 或 unless 區塊。

{% if user.fullname == 'Dave Bowman' %}

Hello, Dave.

{% elsif user.fullname == 'John Smith' %}

Hello, Mr. Smith.

{% else %}

Hello, stranger.

{% endif %}

case/when

switch 陳述式,用來比較變數與不同的值,並針對每個值執行不同的程式碼區塊。

{% case user.fullname %}

{% when 'Dave Bowman' %}

Hello, Dave.

{% when 'John Smith' %}

Hello, Mr. Smith.

{% else %}

Hello, stranger.

{% endcase %}

請參閱

反覆項目標籤
變數標籤
範本標籤
Dataverse 資料表標籤

注意

是否能請您告知您偏好的慣用文件語言? 請填寫問卷。 (請注意,本問卷為英文版)

完成問卷大約需要七分鐘。 本問卷將不會收集個人資料 (隱私權聲明)。