研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
内嵌输入源与外部输入源
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
输入可以内嵌呈现,也可以外部呈现。此属性用于控制值输入的连接器是在块内(内嵌)还是在块外边缘(外部)呈现,以及输入是在同一行还是不同行中呈现。

块定义可以指定一个可选的布尔值,用于控制输入是否内嵌。
JSON
{
// ...,
"inputsInline": true
}
JavaScript
init: function() {
// ...
this.setInputsInline(true);
}
当此布尔值设置为 true
(内嵌输入源)时:
- 值输入的连接器在块内呈现。
- 陈述输入内容会单独显示在一行中。
- 虚拟输入、行尾输入和值输入都呈现在同一行中,但语句或行尾输入之后的任何输入都会呈现在新行中。
当设置为 false
(外部输入源)时:
- 值输入的连接器呈现在代码块的外边缘。
- 所有输入都显示在各自的行中,但紧跟在虚拟输入后面的行尾输入会显示在与虚拟输入相同的行中。
如果您难以直观地理解这一点,可以在 Blockly 开发者工具中构建块,并为 inputs
下拉菜单选择不同的设置(automatic
、external
、inline
)。
如果未定义此布尔值,Blockly 将使用一些启发式方法来猜测哪种模式最适合。假设 Blockly 做出了正确的选择,最好将此字段保留为未定义状态,因为不同的语言翻译可以自动采用不同的模式。请参阅插值令牌顺序中 "set %1 to %2"
(外部输入)和 "put %2 in %1"
(内嵌输入)的示例。
当某个块可能包含数字等小输入时,请使用内嵌输入。
用户可以通过上下文菜单切换此选项。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Inline vs. external inputs\n\nInputs can be rendered **inline** or **externally**. This controls whether the\nconnectors for value inputs are rendered inside the block (inline) or on the\noutside edge (external), as well as whether inputs are rendered in the same or\ndifferent rows.\n\nThe block definition can specify an optional boolean controlling whether inputs\nare inline or not. \n\n### JSON\n\n {\n // ...,\n \"inputsInline\": true\n }\n\n### JavaScript\n\n init: function() {\n // ...\n this.setInputsInline(true);\n }\n\nWhen this boolean is set to `true` (inline inputs):\n\n- The connectors for value inputs are rendered inside the block.\n- Statement inputs are rendered on their own row.\n- Dummy, end-of-row, and value inputs are all rendered in the same row, except that any input following a statement or end-of-row input is rendered on a new row.\n\nWhen it is set to `false` (external inputs):\n\n- The connectors for value inputs are rendered on the outside edge of the block.\n- All inputs are rendered in their own row, except that an end-of-row input that follows a dummy input is rendered in the same row as the dummy input.\n\nIf you're having trouble visualizing this, construct blocks in the\n[Blockly Developer Tools](https://google.github.io/blockly-samples/examples/developer-tools/index.html) and choose different settings for the\n`inputs` dropdown (`automatic`, `external`, `inline`).\n\nIf this boolean is not defined then Blockly will use some heuristics to guess\nwhich mode is\nbest. Assuming Blockly makes the right choice, leaving this field undefined\nis preferable since different language translations can automatically have\ndifferent modes. See the example of `\"set %1 to %2\"` (external inputs) and\n`\"put %2 in %1\"` (inline inputs) in [Interpolation token\norder](/blockly/guides/create-custom-blocks/define/structure-json#interpolation_token_order).\n\nUse inline inputs when a block is likely to have small inputs such as numbers.\nThe user can toggle this option through the context menu."]]