Ember.js: App.register 在 app.js 中未定义
Ember.js: App.register undefined in app.js
当 运行 我的应用 DEPRECATION: Using the Ember.Location.registerImplementation is no longer supported. Register your custom location implementation with the container instead.
时,我收到了一条弃用消息:代码在 app.js.
它用于 hashbang 功能,我看到有人已经为此编写了一个很好的实现:
所以我从字面上复制并粘贴了该代码。但是在摆弄之后我无法让它工作。这是因为 App.register 报错: Uncaught TypeError: undefined is not a function
我也用 App.__container__.register
测试过。但是,这也行不通。最新的 Ember CLI 是否有我不知道的变化?
Ember CLI 不使用 App
作为全局命名空间,它使用 ES6 模块。
您可以在 app/initialzers
中创建一个新的初始化程序:
export default {
name: 'hashbang',
initialize: function(container, application) {
// your code here
}
}
初始化程序作为参数传递给容器。
当 运行 我的应用 DEPRECATION: Using the Ember.Location.registerImplementation is no longer supported. Register your custom location implementation with the container instead.
时,我收到了一条弃用消息:代码在 app.js.
它用于 hashbang 功能,我看到有人已经为此编写了一个很好的实现:
所以我从字面上复制并粘贴了该代码。但是在摆弄之后我无法让它工作。这是因为 App.register 报错: Uncaught TypeError: undefined is not a function
我也用 App.__container__.register
测试过。但是,这也行不通。最新的 Ember CLI 是否有我不知道的变化?
Ember CLI 不使用 App
作为全局命名空间,它使用 ES6 模块。
您可以在 app/initialzers
中创建一个新的初始化程序:
export default {
name: 'hashbang',
initialize: function(container, application) {
// your code here
}
}
初始化程序作为参数传递给容器。