无法阅读财产' tz'未定义 - Ember Moment Timezone

时间:2015-02-15 21:05:45

标签: javascript ember.js timezone momentjs

我有一个ember应用程序,我正在尝试将时区添加到:

{
  "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"
  }
}

我在我的Brocfile.js中使用此行加载js文件:

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

当我启动ember服务器时,即使在我的任何自定义脚本中调用时刻之前,我也会收到以下错误:

 Uncaught TypeError: Cannot read property 'tz' of undefined

有人能告诉我加载时刻时区的正确方法吗? 谢谢!

1 个答案:

答案 0 :(得分:10)

您需要在导入Moment Timezone之前导入Moment。

请参阅http://momentjs.com/timezone/docs/