View Ember.js视图在转换时消失

View Ember.js视图在转换时消失,view,ember.js,transition,routes,View,Ember.js,Transition,Routes,不知何故,即使是在最简单的示例中,当我尝试转换到另一个状态/路线时,视图也消失了 我的索引路径如下所示: --Application------------------------------- | --Header-------------------------------- | | | --ViewA----------------------------- | | | | | View A! | | | | | |____________

不知何故,即使是在最简单的示例中,当我尝试转换到另一个状态/路线时,视图也消失了

我的索引路径如下所示:

--Application-------------------------------
| --Header-------------------------------- |
| | --ViewA----------------------------- | |
| | | View A!                          | | |
| | |__________________________________| | |
| |                                      | |
| | --ViewB----------------------------- | |
| | | View B!                          | | |
| | |__________________________________| | |
| |______________________________________| |
|                                          |
| --Main---------------------------------- |
| | I stay here, no matter what!         | |
| |______________________________________| |
|__________________________________________|
--Application-------------------------------
| --Header-------------------------------- |
| | --ViewA----------------------------- | |
| | | View A!                          | | |
| | |__________________________________| | |
| |______________________________________| |
|                                          |
| --Main---------------------------------- |
| | I stay here, no matter what!         | |
| |______________________________________| |
|__________________________________________|
当我进入“下一个”状态时,ViewB将消失,如下所示:

--Application-------------------------------
| --Header-------------------------------- |
| | --ViewA----------------------------- | |
| | | View A!                          | | |
| | |__________________________________| | |
| |                                      | |
| | --ViewB----------------------------- | |
| | | View B!                          | | |
| | |__________________________________| | |
| |______________________________________| |
|                                          |
| --Main---------------------------------- |
| | I stay here, no matter what!         | |
| |______________________________________| |
|__________________________________________|
--Application-------------------------------
| --Header-------------------------------- |
| | --ViewA----------------------------- | |
| | | View A!                          | | |
| | |__________________________________| | |
| |______________________________________| |
|                                          |
| --Main---------------------------------- |
| | I stay here, no matter what!         | |
| |______________________________________| |
|__________________________________________|

在这个示例应用程序中可以看到这种行为,如果您不指定它在新路由上执行任何操作,它看起来会变得混乱,并且不会呈现所有的出口。使事情正常工作的方法是在
NextRoute
中包含您希望路由再次呈现的内容

App.NextRoute = Ember.Route.extend({
        renderTemplate: function () {
        this.render('header', {'outlet':'header', 'into':'application'});
        this.render('main', {'outlet':'main', 'into':'application'});

        this.render('viewB', {'outlet':'viewB', 'into':'header'});
        this.render('viewA', {'outlet':'viewA', 'into':'header'});
    }
});

如果将
this.render('viewB',{'outlet':'viewB','换成':'header'});
this.render('viewA',{'outlet':'viewA','换成':'header'})
在对
NextRoute
进行更改之前,在索引路径中,您将看到它现在只呈现viewB!奇怪,是吗?我不确定在当前时间点上它是一个bug还是一个功能。

我不确定您的预期行为,但最好将
IndexRoute
抽象出来,因为您在每条路线,否则将被删除:


然而,您的示例似乎很复杂。我认为您的解决方案在于
{{render}
。请看我在这里的帖子:

这对我来说似乎是一个bug,因为这里有一个IRC用户的另一个奇怪的例子。视图a和B现在在模板中被引用,但“主”模板现在消失了:p.s.:哦,顺便说一句,在我明确告诉ember这样做之前,DOM中没有任何变化。我看不到任何逻辑上的变化ason只是因为您更改了状态而导致当前DOM更新。哦,如果您不指定路由,则似乎会忽略路由的最后一行,而不会重新渲染。请参阅JSFIDLE。看起来最后渲染的内容在转换到新状态时消失。正如您在上面的注释和回答中清楚看到的,它只会删除上次通过此.render()添加的模板。此示例背后的原因是有一个在整个应用程序生命周期内保持“活动”的插座。我需要它,因为我有一个嵌入式flash应用程序,该应用程序向用户网络摄像头和摄像头请求权限,并且只能请求一次。一旦我必须将其重新添加到dom中,它将再次请求权限。作为临时解决方案,您可以使flash应用程序不是路由中最后一个
this.render
?作为实际解决方案,您可以使用
{{render}}
将flash应用程序永久呈现到屏幕上,没有?插座是易变的,您应该将持久视图放置在它们之外。