【问题标题】:How to use momentjs npm-package in an angular2-meteor application?如何在 angular2-meteor 应用程序中使用 momentjs npm-package?
【发布时间】:2016-11-06 12:37:33
【问题描述】:

我想在我的 angular2-meteor 应用程序中使用 moment.js 库。为此,我安装了 npm 包:

meteor npm install moment --save

现在,在我想使用这个库的组件中,我必须以某种方式导入它:

import {???} from 'moment';

但是这里必须要导入什么,所以我可以在组件的某处使用它,方式如下:

var foo = moment().format('LLLL');

【问题讨论】:

    标签: meteor momentjs angular2-meteor


    【解决方案1】:

    我在我的一个 angular2-meteor 应用程序中使用了 moment。使用 moment.js 你应该像这样导入它

    import * as moment from 'moment';
    

    并删除它并像这样使用它。

    current_year_header: any;
    date: any;
    this.date = moment();
    this.current_year_header = this.date.format('YYYY');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-24
      • 2017-05-11
      • 1970-01-01
      • 2016-12-12
      • 2018-02-11
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多