研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
工具箱
该工具箱包含用于编程的块。您可以将这些块拖动到工作区中。
如需详细了解工具箱的外观,请参阅视觉术语表。
基本定义
工具箱定义指定了工具箱中包含哪些块以及包含哪些块顺序。工具箱的大部分外观和样式都是通过其他方式指定的。
我们建议您使用 JSON 定义工具箱。
以下代码段定义了一个包含两个块的弹出式工具箱:
const toolbox = {
// There are two kinds of toolboxes. The simpler one is a flyout toolbox.
kind: 'flyoutToolbox',
// The contents is the blocks and other items that exist in your toolbox.
contents: [
{
kind: 'block',
type: 'controls_if'
},
{
kind: 'block',
type: 'controls_whileUntil'
}
// You can add more blocks to this array.
]
};
// The toolbox gets passed to the configuration struct during injection.
const workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});

如需详细了解如何定义和配置工具箱,请参阅工具箱概览。
如需详细了解注入,请参阅创建工作区。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-11-04。
[null,null,["最后更新时间 (UTC):2024-11-04。"],[[["The Blockly toolbox houses programming blocks that users can drag onto the workspace to build programs."],["Toolboxes are typically defined using JSON to specify which blocks are included and their arrangement."],["The provided code snippet demonstrates creating a basic flyout toolbox containing 'controls_if' and 'controls_whileUntil' blocks."],["Further information regarding toolbox configuration and workspace injection can be found in the linked resources."]]],["The toolbox, containing program blocks, is defined using JSON and can be dragged onto the workspace. A flyout toolbox, a simpler type, is specified by its `kind` and `contents`. The `contents` array lists blocks, defined by their `kind` and `type`, such as `controls_if` and `controls_whileUntil`. This toolbox definition is then passed to the configuration during the workspace injection process using `Blockly.inject`.\n"]]