【问题标题】:meteor moment timezone not working流星时刻时区不起作用
【发布时间】:2016-05-04 20:48:47
【问题描述】:

我得到了错误: 模板助手中的异常:TypeError: time.tz is not a function

代码:

Template.registerHelper( 'timeAgo', function ( timestamp ) {
if ( timestamp ) {
let time   = moment( timestamp ),
let timezone =  Session.get("timezone");

return  time.tz(timezone).fromNow();
}
});

我已经安装了 momentjs:moment,它工作正常。

问题出在 timezone 包上:我已经安装了 aldeed:moment-timezone 包,然后我尝试使用 mrt:moment-timezone 包但没有;它也不起作用。

【问题讨论】:

    标签: meteor timezone momentjs


    【解决方案1】:

    也许您使用类似的方式加载了 moment

    var moment = require('moment');
    

    代替:

    var moment = require('moment-timezone');
    

    【讨论】:

      猜你喜欢
      • 2018-03-03
      • 2019-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-06
      • 2013-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多