研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
流程概览
在计算机科学术语中,过程是执行特定任务的可重复使用的位代码。
Blockly 将过程实现为一组块,这些块可生成用于定义过程的代码,并对其进行调用。

→ 详细了解如何使用代码块。
→ 详细了解如何创建自定义过程块。
→ 详细了解如何创建自定义手术模型,您可以通过模型添加类型化参数等新功能。
内置与插件
Blockly 提供过程块的两种实现。
一个存在于插件 @blockly/block-shareable-procedures 中,用于实现依赖于后备数据模型的过程块。这样,您就可以对过程块执行一些操作,例如让定义块位于一个工作区中,而调用块位于另一个工作区中。该插件是过程块的推荐实现。
另一个是 Blockly Core 中提供的旧版实现。这些块没有后备数据模型,且有关过程的所有信息都来自块本身。工作区知道哪些过程可用的唯一方法是检查该工作区中包含的过程定义块。为了实现向后兼容性,这些块继续获得支持,但大多数开发者应该能够使用该插件提供的新块。
如果您使用 XML 序列化,则可以使用新的块,但它们无法在工作区之间共享。该功能需要额外的序列化,而该序列化方式仅由 JSON 序列化器提供。使用 XML 时,新块的行为方式与旧版块相同。详细了解如何升级到 JSON。
如果您已定义自定义过程块,则需要更新它们才能使用新数据模型。
如果您已定义自定义过程定义块,但使用的是内置过程调用块,则需要继续使用旧版调用方块,直到更新定义块为止。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-12-02。
[null,null,["最后更新时间 (UTC):2023-12-02。"],[[["In Blockly, procedures are reusable code blocks that execute specific tasks, allowing users to define and call them within their projects."],["Blockly offers two procedure block implementations: a recommended plugin-based approach with data models for advanced features and a legacy core implementation for backward compatibility."],["The plugin-based implementation enables procedure sharing across workspaces when utilizing JSON serialization, whereas XML serialization limits sharing but functions similarly to legacy blocks."],["Custom procedure blocks require updates to ensure compatibility with the newer data models introduced by the plugin-based implementation."],["When using custom procedure definition blocks with built-in procedure call blocks, it's necessary to retain the legacy caller block until the definition block is updated for compatibility."]]],["Blockly uses blocks to define and call procedures, which are reusable code segments. It offers two implementations: a recommended plugin (@blockly/block-shareable-procedures) with a backing data model for features like cross-workspace sharing, and a legacy core implementation without a data model. The plugin blocks support JSON serialization for sharing; XML serialization is limited. Custom procedure blocks must be updated to use the new data models. Custom definition blocks used with the built-in caller block should use legacy caller blocks until the definition block is updated.\n"]]