简体   繁体   English

流星JS:动态布局模板

[英]Meteor JS: Dynamic Layout Template

I want to make the layout template dynamic. 我想使布局模板动态化。 The value of the layout template would be fetch in the server using a Meteor.call 'getLayoutTemplate'. 布局模板的值将使用Meteor.call'getLayoutTemplate'在服务器中获取。 Where shall I put the Meteor.call? 我应该把Meteor.call放在哪里? And it should wait until it fetches the value of the Meteor.call. 它应该等待,直到获取Meteor.call的值。 Any ideas? 有任何想法吗?

Router.configure
  layoutTemplate: ????
  notFoundTemplate: 'notFound'

I would put the method call in a onAfterAction hook and then set the layoutTemplate depending on the call's result: 我将方法调用放在onAfterAction挂钩中,然后根据调用结果设置layoutTemplate

Router.route('/route', {
  name: 'route',
  onAfterAction: function() {
    var routerInstance = this;
    Meteor.call('method', function(error, result) {
      routerInstance.layoutTemplate = result;
    });
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM