gutenbergdocs/docs/reference-guides/block-api/block-api-versions.md
2025-10-22 01:40:18 +08:00

16 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# API 版本说明
本文档记录了不同 API 版本之间的变更内容。
## 版本 3适用于 WordPress 6.3 及以上版本)
- 当所有已注册区块均采用区块 API 第 3 版或更高版本时,文章编辑器将采用 iframe 内嵌模式。支持第 3 版意味着区块应能在 iframe 内正常工作,但若存在不支持第 3 版的区块,该区块仍可能在 iframe 外渲染。
- 请参阅[本文](https://make.wordpress.org/core/2021/06/29/blocks-in-an-iframed-template-editor/)获取迁移指南,了解如何将 API 版本升级至第 3 版并确保在 iframe 编辑器中正常运行。
## 版本 2适用于 WordPress 5.6 及以上版本)
- 区块开发者必须使用 `useBlockProps()` 钩子函数来渲染区块 `edit` 实现的包装元素。
- 在处理 `save` 功能时,生成的类名和样式不再自动添加到静态区块的保存标记中。如需保留这些样式,区块开发者必须显式调用 `useBlockProps.save()` 并将其添加到区块包装器中。
## 版本 1
初始版本。