【问题标题】:Gutenberg NPM doesn't do any changesGutenberg NPM 不做任何更改
【发布时间】: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


【解决方案1】:

一切都在浏览器缓存中..您可以使用私人浏览器或在每次尝试进行任何更改时清理浏览器缓存..您会发现您的更新看起来不错

【讨论】:

    猜你喜欢
    • 2017-02-07
    • 2017-08-17
    • 2016-03-31
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 2012-09-04
    • 2015-09-14
    • 2020-07-09
    相关资源
    最近更新 更多