简体   繁体   English

如何在Meteor中使用本机客户端库?

[英]How to use native client-side libraries in Meteor?

Current Meteor version: 目前的流星版本:
Preview 0.6.6.3 预览0.6.6.3

I am tying to add client libraries in my Meteor project (on Ubuntu and also on Windows) with Meteor or meteorite, such as Taggle.js . 我想在我的Meteor项目(在Ubuntu和Windows上)添加Meteor或陨石(如Taggle.js )中的客户端库。
Those libraries are not available as packages on Atmosphere. 这些库不能作为Atmosphere的包提供。

I tried to copy and paste my *.js in the .meteor/local/build/programs/client or .meteor/local/build/programs/client/app but it didn't work. 我试图将我的*.js复制并粘贴到.meteor/local/build/programs/client.meteor/local/build/programs/client/app但它不起作用。

How can I put client-side native libraries in my Meteor project? 如何将客户端本机库放入Meteor项目中?

My current application structure: 我目前的申请结构:

my_app/

  • css/
  • pages/
  • js/
  • .meteor/

You shouldn't manually mess with files in .meteor directory (except for packages and release files), that's where Meteor puts its compiled files. 你不应该手动搞乱.meteor目录中的文件( packagesrelease文件除外),这是Meteor放置其编译文件的地方。 All libraries should go to source folder - so basically anywhere else. 所有库都应该到源文件夹 - 所以基本上在其他地方。

I assume those are client-side libraries. 我假设这些是客户端库。

In that case, put them: 在这种情况下,把它们:

  • in /client if it doesn't matter when they are loaded and they happen to work there; in /client如果加载它们并且它们碰巧在那里工作并不重要;
  • in /client/lib if you need to load them before the rest of the code; /client/lib如果需要在其余代码之前加载它们;
  • in /client/compatibility if the code is not prepared to work with Meteor and you don't want to / don't know how to fix it; in /client/compatibility如果代码不准备与Meteor一起使用,而你不想/不知道如何修复它;
  • in /client/lib/compatibility if both of the above conditions occur. /client/lib/compatibility如果出现上述两种情况。 I'd recommend to put them here on the beginning just to be safe. 为了安全起见,我建议把它们放在开头。

If you want to load HTML/CSS/JS files dynamically to your meteor application then you can use: Meteor-external-file-loader 如果要将HTML / CSS / JS文件动态加载到流星应用程序,则可以使用: Meteor-external-file-loader

Add Meteor-external-file-loader to your meteor app by typing in console: 通过键入console,将Meteor-external-file-loader添加到您的meteor应用程序:

meteor add mrt:external-file-loader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM