【发布时间】:2016-03-05 12:48:10
【问题描述】:
拥有一个带有 Bootstrap 的 Meteor 应用程序(手动插入到 public/javascript 目录中)。每次执行应用程序时,我都会得到以下信息:
Exception from Tracker afterFlush function:
debug.js:41 TypeError: $(...).scrollspy is not a function
at eval (eval at <anonymous> (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:365:22), <anonymous>:20:15)
at eval (eval at <anonymous> (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:365:22), <anonymous>:48:3)
at eval (native)
at http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:365:22
at Function.jQuery.extend.globalEval (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:366:7)
at jQuery.ajaxSetup.converters.text script (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:9792:11)
at ajaxConvert (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:8864:18)
at done (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:9285:15)
at callback (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:9739:8)
at Object.send (http://localhost:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:9745:7)
我检查了 'public/javascript/bootstrap.js' 文件并且有一个函数 'ScrollSpy(element, options)' 所以 它似乎是一个函数。因此,不知道这里出了什么问题......
编辑:
我正在将文件加载到 layout.js 文件中:
Template.layout.rendered = function() {
$('head').append('<script type="text/javascript" src="/frontend/javascript/jquery.easing.min.js"></script>');
$('head').append('<script type="text/javascript" src="/frontend/javascript/jquery.easing.min.js"></script>');
$('head').append('<script type="text/javascript" src="/frontend/javascript/jquery.fittext.js"></script>');
$('head').append('<script type="text/javascript" src="/frontend/javascript/wow.min.js"></script>');
$('head').append('<script type="text/javascript" src="/frontend/javascript/creative.js"></script>');
}
奇怪的是我没有加载引导 javascript,但我仍然获得引导布局和功能。在上面的 layout.js 中加载最小化的引导程序会导致没有导航菜单(它在那里但不显示)
编辑:目录结构
client
helpers
lib
frontend
css
templates
authenticated
layouts
public
lib
public
frontend
fonts
img
javascript
server
...
【问题讨论】:
-
公共文件不会自动加载到应用程序中。您是否在任何地方都包含这些脚本?