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

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

问题描述

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

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和meteor的方法吗?
  • 有没有办法在流星中使用 npm 包?

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

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

推荐答案

对于诸如 moment.js、validate.js、underscore.string.js 等独立 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).

如果您使用meteorite,您可以利用大气 包.您正在寻找的某些内容可能在其中.

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

使用来自meteor 的npm 模块是很多人问的问题(有充分的理由).你可以在这里看到一些注释,虽然我是先听到的目前,meteor 与 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天全站免登陆