【问题标题】:TypeError: $ is undefined & ReferenceError: Foundation is not definedTypeError: $ is undefined & ReferenceError: Foundation is not defined
【发布时间】:2013-03-03 07:46:20
【问题描述】:

我正在尝试通过drupal 7中的theme.info将foundation.js和foundation-topbar.js版本4添加到page.tpl.php。我可以看到jquery和foundation js文件已正确添加-jquery在foundation js文件之上- 但我得到这个错误:

TypeError: $ is undefined
(Foundation.zj, this, this.document)); // foundation-topbar.js line 206 

 ReferenceError: Foundation is not defined 
 (Foundation.zj, this, this.document)); // foundation-topbar.js line 206

there is foundation-topbar.js

【问题讨论】:

标签: jquery drupal-7 zurb-foundation


【解决方案1】:

您需要按以下顺序添加到脚本的链接:

  1. Zepto 或 jQuery(但不能同时使用,Zepto 在 Foundation 4 中取代了 jQuery)
  2. foundation.js
  3. foundation-topbar.js

$ 是 jQuery 调用和函数的简写。所以$('')jQuery('') 相同,Zepto 使用$ 并且与 jQuery 兼容,因此您可能会同时加载冲突,但如果没有看到源则很难判断。

【讨论】:

    【解决方案2】:

    它正在寻找的“基础”是类对象。您需要包含与您正在使用的 js 库位于同一目录中的foundation.js。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 2014-03-03
      • 2018-09-07
      • 2022-11-10
      • 2018-12-26
      • 2020-06-14
      • 2019-02-08
      相关资源
      最近更新 更多