Uncaught Error: No Iron.Layout found so you can't use yield

故事扮演 提交于 2019-12-05 06:03:11

This is not how iron:router layouts are supposed to work.

Get rid of your explicit inclusion of the layout in the body :

{{! this is WRONG, remove the body tag altogether }}
<body>
    {{> defaultLayout}}
</body>

The place where your specify the layoutTemplate is in the RouteController :

Router.route('/', function () {
  this.render('home');
},{
 layoutTemplate:"defaultLayout" 
});

Declaring explicitly your RouteControllers is usually a nicer design pattern.

lib/router.js

Router.route("/",{
  // give the route a name so it figures out itself to use :
  // - HomeController
  // - a template name "home"
  name:"home"
});

lib/controllers/lib/default-layout.js

DefaultLayoutController=RouteController.extend({
  layoutTemplate:"defaultLayout"
});

lib/controllers/home.js

HomeController=DefaultLayoutController.extend({
  //
});
Helmi

Well, like your error says you're missing an iron layout.

Could look something like this in your lib/router.js or wherever you hold your router code:

Router.configure({
    layoutTemplate: 'layout',
    loadingTemplate: 'loading'
});

And so the respective <template name="layout"> should be there.

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