Cannot read property 'tz' of undefined - Ember Moment Timezone

我与影子孤独终老i 提交于 2019-12-11 01:43:55

问题


I have an ember app that I am trying to add moment with time zone into:

{
  "name": "front-end",
  "dependencies": {
    "handlebars": "~1.3.0",
    "jquery": "^1.11.1",
    "ember": "1.8.1",
    "ember-data": "~1.0.0-beta.14.1",
    "ember-resolver": "~0.1.7",
    "loader.js": "stefanpenner/loader.js#1.0.1",
    "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
    "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
    "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
    "ember-qunit": "0.1.8",
    "ember-qunit-notifications": "0.0.4",
    "qunit": "~1.17.1",
    "bootstrap": "~3.3.2",
    "ember-simple-auth": "0.7.3",
    "jquery-autosize": "~1.18.12",
    "moment-timezone": "~0.3.0"
  }
}

I load the js file with this line in my Brocfile.js:

app.import('bower_components/moment-timezone/builds/moment-timezone-with-data-2010-2020.min.js');

When I start the ember server I get the following error even before I call moment in any of my custom scripts:

 Uncaught TypeError: Cannot read property 'tz' of undefined

Could anyone tell me the proper way to load moment-timezone? Thanks!


回答1:


You need to import Moment before importing Moment Timezone.

See http://momentjs.com/timezone/docs/



来源:https://stackoverflow.com/questions/28531167/cannot-read-property-tz-of-undefined-ember-moment-timezone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!