0

我一直在尝试将我的引导主题转换为 WordPress 主题,但是一旦我添加了我的 js 文件,我就会得到这个内存错误。

错误看起来像这样

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in C:\xampp\htdocs\livedinner\wp-includes\class.wp-dependencies.php on line 312

这是我的代码


function theme_js()
{

     wp_enqueue_scripts('popper_js',get_template_directory_uri() . 'js/popper.min.js' , array('jquery'),
            '1',
            true );    


}



add_action('wp_enqueue_scripts','theme_js');
4

1 回答 1

0

如果有人有这个问题。好消息!我找到了解决办法。我们应该添加这样的脚本


function blogsite_regitser_scripts()
{

    wp_enqueue_script('blogsite-jquery','https://code.jquery.com/jquery-3.4.1.slim.min.js',array(),'3.4.1',true);

}

add_action('wp_enqueue_scripts','blogsite_regitser_scripts');

早些时候我使用的是 wp_enqueue_scripts 而 wp_enqueue_scripts 是一个完全不同的函数。你可以在这里阅读更多https://developer.wordpress.org/reference/functions/wp_enqueue_script/

于 2020-08-06T20:03:17.057 回答