Javascript 在meteor应用程序中,为什么需要将一些外部脚本放在客户机/子目录中?
当我放置捕鼠器javascript文件时(http://craig.is/killing/mice)在我的Meteor应用程序的主目录中,我遇到以下错误:Javascript 在meteor应用程序中,为什么需要将一些外部脚本放在客户机/子目录中?,javascript,meteor,Javascript,Meteor,当我放置捕鼠器javascript文件时(http://craig.is/killing/mice)在我的Meteor应用程序的主目录中,我遇到以下错误: Your app is crashing. Here's the latest log. app/mousetrap.js:711 _addEvent(document, 'keypress', _handleKey); ^ ReferenceError: document is not defined
Your app is crashing. Here's the latest log.
app/mousetrap.js:711
_addEvent(document, 'keypress', _handleKey);
^
ReferenceError: document is not defined
at app/mousetrap.js:711:15
at app/mousetrap.js:813:4
at /Users/Suchow/Desktop/Collective/.meteor/local/build/server/server.js:107:21
at Array.forEach (native)
at Function._.each._.forEach (/Users/Suchow/Desktop/Collective/.meteor/local/build/server/underscore.js:76:11)
at run (/Users/Suchow/Desktop/Collective/.meteor/local/build/server/server.js:93:7)
Exited with code: 1
Your application is crashing. Waiting for file change.
当捕鼠器文件放置在客户机/子目录中时,错误消失。为什么?因为服务器端没有dom。 如果你把它放在根目录下,它已经被加载到服务器端和客户端
与sugarjs一样,momentjs可以同时工作。在Meteor 1.0中,在创建包时,强制Meteor仅在客户端加载第三方库的方法是显式地将
client
参数传递给api.addFiles
文件中的api.addFiles
Package.onUse(function(api) {
api.addFiles('lib/thirdpartylibrary.js', 'client');
}