如何在Meteor中使用`moment.js`? [英] How to use `moment.js` with Meteor?

查看:51
本文介绍了如何在Meteor中使用`moment.js`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将momentjs与流星一起使用.这是一个npm软件包,所以据我所知,它不能与流星一起使用,因为流星使用它自己的软件包系统.所以这是我的问题:

I am wanting to use momentjs with meteor. This is an npm package, so from what I understand, it cannot be used with meteor because meteor uses it's own package system. So here are my questions:

  • 有人知道在流星上使用momentjs的方法吗?
  • 有没有办法在流星上使用npm软件包?

2017编辑:从Meteor 1.4+开始,npm软件包管理允许标准导入npm模块和命名导入的Atmosphere模块.

2017 EDIT: As of Meteor 1.4+, npm package management allows for standard imports of npm modules and named imports of Atmosphere modules.

推荐答案

对于独立的js库,例如moment.js,validate.js,underscore.string.js等,您只需将源文件放入lib文件夹.我将client/lib用于仅在客户端上使用的库(例如validate.js),并将lib用于可以同时在客户端和服务器上使用的库(例如moment.js).

For stand-alone js libraries like moment.js, validate.js, underscore.string.js, etc. you can just drop the source file into your lib folder. I use client/lib for libraries which will be used only on the client (like validate.js), and lib for libraries which could be used by both the client and the server (like moment.js).

如果您使用陨石,则可以利用

If you use meteorite, you can take advantage of the atmosphere packages. Some of what you are looking for for may be in there.

使用流星的npm模块是很多人问的问题(有充分的理由).您可以在此处看到一些笔记,尽管我首先听说过流星与npm软件包的对话方式即将发生重大变化.

Using npm modules from meteor is something a lot of people ask about (for good reason). You can see some notes here, though I heard first hand that the way meteor talks to npm packages is about to change significantly.

这篇关于如何在Meteor中使用`moment.js`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆