【问题标题】:Twitter bootstrap. bootstrap javascript is working but others script wont推特引导。引导 javascript 正在工作,但其他脚本不会
【发布时间】:2014-08-17 16:57:57
【问题描述】:

我想知道为什么我的其他脚本无法运行,但 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)在 LOCALHOST 中运行良好。但是,当我上传我的 wordpress 网站时。此脚本不再起作用。有人可以帮忙吗?顺便说一下,这 3 个脚本用于 PAGE SCROLLING。

【问题讨论】:

标签: javascript php jquery wordpress twitter-bootstrap


【解决方案1】:

也许您将“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 语句时加载的。

【讨论】:

  • 感谢您的回复@yitwail 好的,我删除了 jquery-1.11.0.js,但它仍然无法正常工作。我的 custom.js 具有页面滚动效果,而 jquery-easy-min.js 是它的插件,如何具体链接呢?我有点困惑。菜鸟在这里。对不起。
【解决方案2】:

在引导之前添加 jQuery。 Bootstrap 依赖它

【讨论】:

    猜你喜欢
    • 2021-08-27
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    相关资源
    最近更新 更多