gpt4 book ai didi

ember.js - 断言失败: An outlet (menu) was specified but this view will render at the root level

转载 作者:行者123 更新时间:2023-12-02 19:05:39 25 4
gpt4 key购买 nike

当我在应用程序的根级别渲染额外的导出时,出现了这个奇怪的断言错误。

这是我使用的代码:

<div id="app">
<nav>{{outlet "menu"}}</nav>
<div class="content">{{outlet}}</div>
</div>

我有一个名为menu的模板。这是我的 App.ApplicationRout

app.ApplicationRoute = Ember.Route.extend({
renderTemplate: function() {
this.render();
this.render("menu", {
outlet: "menu"
});
}
});

但它抛出一个错误:断言失败:指定了导出(菜单),但此 View 将在根级别呈现

最佳答案

我发现了问题,在根级别,您应该在 render 函数中传递 into 属性:

app.ApplicationRoute = Ember.Route.extend({
renderTemplate: function() {
this.render("menu", {
outlet: "menu",
into: 'application'
});
return this._super.apply(this,arguments);
}
});

现在它渲染得很好。

关于ember.js - 断言失败: An outlet (menu) was specified but this view will render at the root level,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15116634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com