我遇到了Meteor和Jquery的问题。我添加了underscore.js和jquery但是当我尝试运行代码时仍然遇到跟随错误。服务器在启动之前就会失败。
任何帮助将不胜感激。
这是输出窗口的副本。我知道我错过了一些非常简单的事情。我可以让其他流星应用程序运行。
=> Meteor server running on: localhost:3000/
.meteor\local\build\server\server.js:34
5
}).run();
^
ReferenceError: jQuery is not defined
at app/lib/jquery-ui.custom.min.js:4:4148
at \.meteor\local\build\server\serve
r.js:306:12
at Array.forEach (native)
at Function._.each._.forEach (C:\Users\rodgerse\node_modules\underscore\unde
rscore.js:79:11)
at run (\.meteor\local\build\server\
server.js:239:7)
=> Exited with code: 1
=> Meteor server restarted
\.meteor\local\build\server\server.js:34
5
}).run();
^
ReferenceError: jQuery is not defined
at app/lib/jquery-ui.custom.min.js:4:4148
at \.meteor\local\build\server\serve
r.js:306:12
at Array.forEach (native)
at Function._.each._.forEach (C:\Users\rodgerse\node_modules\underscore\unde
rscore.js:79:11)
at run (\.meteor\local\build\server\
server.js:239:7)
=> Exited with code: 1
=> Meteor server restarted
\.meteor\local\build\server\server.js:34
5
}).run();
^
ReferenceError: jQuery is not defined
at app/lib/jquery-ui.custom.min.js:4:4148
at \.meteor\local\build\server\serve
r.js:306:12
at Array.forEach (native)
at Function._.each._.forEach (C:\Users\rodgerse\node_modules\underscore\unde
rscore.js:79:11)
at run (\.meteor\local\build\server\
server.js:239:7)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
答案 0 :(得分:3)
要遍历服务器上的数组,您应该使用下划线的._each
方法。它附带了Meteor,因此没有可以安装的软件包或类似的东西。
所以,而不是:
$.each(someArray, function (index, element) {
//Some awesome logic
})
你可以这样做:
_.each(someArray, function (element, index, list) {
//Some awesome logic.
});
Check this out了解更多信息。
答案 1 :(得分:1)
jQuery仅在客户端上可用 - 而不是服务器[1]。因此,因为它依赖于jQuery,所以您的文件只能在客户端上运行。你应该把它放在client
目录中:
app/client/lib/jquery-ui.custom.min.js