【发布时间】:2022-02-09 20:20:09
【问题描述】:
当我在块或其他东西中创建一些更改时的 NPM .. 更改不起作用, 这是我的 gutenberg.php
function MyBlocks()
{
wp_register_script('blocks-js', get_template_directory_uri() . '/build/index.js', array('wp-blocks' , 'wp-editor' , 'wp-components' ));
register_block_type('yusuf/custom-cta', array('editor_script' => 'blocks-js'));
// register_block_type('yusuf/custom-pro', array('editor_script' => 'blocks-js'));
// register_block_type("yusuf/statics" , array('editor_script' => 'blocks-js'));
}
add_action('init', 'MyBlocks');
我评论了这些块,但仍然出现, 并将其从 build/index.js 中删除,仍然显示, 我想知道为什么会发生在我身上! 并且“NPM START”已经运行
【问题讨论】:
-
npm start构建您在src/index.js中定义的块/s,编辑build/index.js文件将无效,因为它将立即在其上重建。我怀疑问题可能出在src/index.js,您能分享一下您是如何在src/index.js中注册块的吗? -
@S.Walsh src/index.js 只是将块导入其中` //Statics Counter Block!从“./Blocks/statics”导入 { staticsBlock };静态块(); //关于我们部分块!从“./Blocks/aboutus”导入{ aboutusBlock};关于usBlock(); `
-
所以
src/index.js中没有导入“yusuf/custom-pro”和“yusuf/statics”这两个块,它们仍然显示在编辑器中?听起来像是浏览器中的缓存问题。尝试停止 npm 并清除浏览器缓存以确保您没有看到旧版本,然后使用npm start重新启动构建 - 问题仍然存在吗? -
@S.Walsh 一直都是这样兑现的,顺便说一句,谢谢你的帮助.. 下次我会更加关注
标签: javascript wordpress npm wordpress-gutenberg gutenberg-blocks