Ember.js:App.register在app.js中未定义

时间:2015-01-12 13:49:15

标签: ember.js ember-cli

运行我的应用时收到了弃用消息:DEPRECATION: Using the Ember.Location.registerImplementation is no longer supported. Register your custom location implementation with the container instead.。代码在app.js中。

这是用于hashbang功能,我看到有人已经为此编写了一个很好的实现:https://stackoverflow.com/a/23055007/1153884

所以我真的复制并粘贴了那段代码。但是在摆弄之后我无法让它发挥作用。这是因为App.register发错了:Uncaught TypeError: undefined is not a function enter image description here

我还使用App.__container__.register进行了测试。然而,这也行不通。使用最新的Ember CLI有什么改变我不知道吗?

1 个答案:

答案 0 :(得分:2)

Ember CLI不使用App作为全局命名空间,它使用ES6模块。

您可以在app/initialzers中创建新的初始值设定项:

export default {
  name: 'hashbang',
  initialize: function(container, application) {
    // your code here
  }
}

初始值设定项作为参数传递给容器。

相关问题