欄位與圖示
欄位和圖示都是顯示在區塊中的視覺元素,但用途不同。
欄位會顯示或定義有關區塊的相關資料,這會影響程式的運作方式。舉例來說,文字區塊有兩個引號,用來指出您要定義字串,以及一個可讓您定義該字串的文字輸入內容。引號可以指出區塊的函式,輸入則可讓您修改函式。
圖示會顯示或定義區塊本身的「中繼」資訊。舉例來說,您可以將註解圖示附加至任何區塊,即可自行撰寫附註,但不會影響程式中的區塊功能。
功能比較
屬性 |
欄位 |
圖示 |
轉譯
|
欄位可以由任何所需元素組成。 |
圖示可以任意設計元素 |
數字
|
欄位可以在一個區塊中出現次數, |
每個圖示可以在一個區塊中出現一次 |
位置 |
欄位可放置在任何區塊輸入的任何位置。 |
圖示一律位於區塊頂端。 |
序列化 |
欄位可以序列化,通常也會進行序列化。 |
圖示可以序列化,但通常不是,因為圖示通常沒有狀態。 |
收合
|
當區塊收合時,系統會隱藏欄位,而改為顯示這些欄位的文字。 |
圖示可以控制是否要在區塊收合時顯示或隱藏圖示。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-12-02 (世界標準時間)。
[null,null,["上次更新時間:2023-12-02 (世界標準時間)。"],[[["Fields define a block's data and functionality, while icons provide metadata or supplemental information about the block."],["Fields can have multiple instances, flexible positioning, and are often serialized, whereas icons are singular, positioned at the top-start, and may not always be serialized."],["Both fields and icons are visual elements on a block and offer flexibility in their rendering using various elements."]]],["Fields and icons are distinct visual elements on a block with different purposes. Fields display or define data affecting a program's function, like the quotation marks and text input on a text block. Icons provide \"meta\" information about a block, such as a comment icon, which doesn't impact program function. Fields can appear multiple times, have varied rendering and placement, and are often serialized. Icons appear once per block, are fixed at the top-start, and are often not serialized, but can control visibility when a block is collapsed.\n"]]