assertion failed: An outlet (menu) was specified but this view will render at the root level

耗尽温柔 提交于 2020-01-24 14:15:31

问题


I have this weird assertion error when I was rendering an extra outlet on the root level of my application.

This is the code I use:

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

I have a template called menu. This is my App.ApplicationRout

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

But it is throwing an error: assertion failed: An outlet (menu) was specified but this view will render at the root level


回答1:


I found the problem, at root level you should pass the into-property in the render-function:

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

Now it renders just fine.



来源:https://stackoverflow.com/questions/15116634/assertion-failed-an-outlet-menu-was-specified-but-this-view-will-render-at-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!