研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
字段与图标
字段和图标都是显示在块上的视觉元素,但用途不同。
字段显示或定义有关块的数据,这些数据会影响程序的运作方式。
例如,文本块有两个引号,表示您正在定义一个字符串,而文本输入则允许您定义该字符串。引号可以说明代码块的功能,而输入的内容则可以修改函数。
图标用于显示或定义有关块本身的“元数据”信息。例如,您可以在任何代码块中附加注释图标,这样,您就可以自行编写备注,但不会影响代码块在程序中的运行方式。
功能比较
属性 |
字段 |
图标 |
渲染
|
字段可以由任何元素组成。 |
图标可以用任何想要的元素组成。 |
数字
|
每个字段可以在一个块中出现任意次数。 |
每个图标可以在一个区块中出现一次。 |
展示位置
|
字段可以放置在块的任何输入上的任意位置。 |
图标始终位于块的顶端。 |
序列化
|
字段可以序列化,并且通常可以序列化。 |
图标可以序列化,但通常不能进行序列化,因为它们通常没有状态。 |
收起
|
当某个块处于收起状态时,字段会被隐藏,而其文本则会显示。 |
图标可以控制在块收起时是显示或隐藏这些图标。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-12-02。
[null,null,["最后更新时间 (UTC):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"]]