我想知道为什么我的其他脚本不能工作,但bootstrap.js可以工作。这里有我的functions.php调用脚本的代码。
<?php
/*Linking of CSS Child Theme to Parent Theme + JavaScript*/
function theme_add_bootstrap()
{
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/css/bootstrap.css' );
wp_enqueue_style( 'custom-css', get_template_directory_uri() . '/css/custom.css' ); <!--Working Javascript -->
wp_enqueue_script( 'bootstrap-js', get_stylesheet_directory_uri().'/js/bootstrap.js', array( 'jquery' ) );
wp_enqueue_script( 'custom-js', get_stylesheet_directory_uri().'/js/custom.js', array( 'jquery' ) );
wp_enqueue_script( 'jquery-easy-min-js', get_stylesheet_directory_uri().'/js/jquery.easy.min.js', array( 'jquery' ) );
wp_enqueue_script( 'jquery-1-js', get_stylesheet_directory_uri().'/js/jquery-1.11.0.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'theme_add_bootstrap' );其他3个脚本(custom.js、jquery.easy.min.js和jquery-1.11.0.js)在本地主机上运行良好。然而,当我上传我的wordpress站点时。这些脚本不再起作用。有人能帮上忙吗?顺便说一下,这3个脚本是用来滚动页面的。
发布于 2014-08-18 01:26:14
也许你把“jquery”拼错了“jqeury”?
wp_enqueue_script( 'jquery-1-js', get_stylesheet_directory_uri().'/js/jqeury-1.11.0.js', array( 'jquery' ) );但是如果没有拼写错误,那么您可能加载了两次jQuery,因为jqeury-1.11.0.js看起来很像jQuery本身。在这种情况下,去掉这一行。Wordpress有它自己的jQuery,你第一次将array('jquery')作为依赖项放入wp_enqueue_script语句时就加载了它。
发布于 2016-06-10 02:13:44
在引导之前添加jQuery。引导依赖于它
https://stackoverflow.com/questions/25351471
复制相似问题