admin管理员组文章数量:1432566
When developing for the Gutenberg / block editor, I see two methods used in various resources. Let's say I wanted to use i18n
The Gutenberg handbook sometimes does it like this:
Define
wp-i18n
as a dependency in thewp_register_script
block.Use
const { __ } = wp.i18n;
in the JavaScript.
But there is also documentation on how to do it like this:
Add
@wordpress/i18n
as a dependency.Use
import { __ } from '@wordpress/i18n';
in the JavaScript.
How do these ways differ and what is considered best practice in WordPress?
本文标签: plugin developmentGutenberg import dependency or assign from global variable
版权声明:本文标题:plugin development - Gutenberg: import dependency or assign from global variable? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745606437a2665864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论