[英]Referencing App in ember-cli
I am having an issue when running my ember-cli app in production mode. 在生产模式下运行ember-cli应用程序时出现问题。 When I reference
App.deferReadiness()
it is acting as if App is undefined. 当我引用
App.deferReadiness()
它的作用就像未定义App。
app/app.coffee app / app.coffee
`import Ember from 'ember'`
`import Resolver from 'ember/resolver'`
`import loadInitializers from 'ember/load-initializers'`
`import config from './config/environment'`
App = Ember.Application.extend
modulePrefix: config.modulePrefix
podModulePrefix: config.podModulePrefix
Resolver: Resolver
ready: ->
Ember.debug "Total setup time: #{(new Date).valueOf() - startTime.valueOf()}ms"
loadInitializers(App, config.modulePrefix)
`export default App`
app/initializers/facebook.coffee 应用程序/初始化程序/facebook.coffee
`import App from 'my_app/app'`
initialize = (container, application) ->
# Results in: t.default.deferReadiness is not a function
App.deferReadiness()
# omitted code
This works fine in development mode, but something is up in production. 这在开发模式下可以正常工作,但是在生产中有成功。 Any ideas?
有任何想法吗?
I was not able to determine why there was a difference between development mode and production, but I was able to find a way to work around the issue. 我无法确定为什么开发模式和生产之间会有差异,但是我能够找到解决此问题的方法。 All of the places I was referring to
App
were in initializers. 我指的所有
App
都是初始化器。 Initializers receive the arguments container
and application
. 初始化程序接收参数
container
和application
。 By using these arguments, I was able to stop using App
. 通过使用这些参数,我能够停止使用
App
。 There was one more reference to App.__container__.lookup
in a controller (I know nasty). 在控制器(我知道很讨厌)中还有一个对
App.__container__.lookup
引用。 This was easy to fix with this.container.lookup
. 使用
this.container.lookup
很容易解决。 I believe these changes resolve my issue. 我相信这些更改可以解决我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.