【问题标题】:Meteor - alternative layout templateMeteor - 替代布局模板
【发布时间】:2015-09-16 00:53:52
【问题描述】:

我有一个布局模板,但想应用一个替代布局模板。我已经创建了 altLayout.html,但如何将它应用到我的路线?

Router.configure({
      layoutTemplate: 'layout',
        notFoundTemplate: 'pageNotFound',
      //waitOn: function() { return Meteor.subscribe('items'); }

    });

    Router.map(function() {
      this.route('main', {
        path: '/',
        template: 'main',
         notFoundtemplate: "pageNotFound",
         oldBrowserTemplate: "oldBrowser",
          onBeforeAction: function () {
                // render the unsupported browser page if user isn't using Chrome
                if(BrowserDetect.browser == "Chrome"){
                    layoutTemplate: 'altLayout',
                    this.render('oldBrowser');
                    this.stop();
                }
          },
      });

    });

【问题讨论】:

    标签: templates meteor iron-router


    【解决方案1】:

    以下对我有用:

    Router.route("/product/:id",
    {
      name: "product_page",
      template: "product_page",
      layoutTemplate: "product_page_layout",
      data: function()
      {
        return {id: this.params.id}
      }
    });
    

    “product_page_layout”是您的 altLayout.html 模板所在的位置。基本上:

    Router.map(function() {
          this.route('main', {
            path: '/',
            template: 'main',
            layoutTemplate: "altLayout",
             notFoundtemplate: "pageNotFound",
             oldBrowserTemplate: "oldBrowser",
              onBeforeAction: function () {
                    // render the unsupported browser page if user isn't using Chrome
                    if(BrowserDetect.browser == "Chrome"){
                        layoutTemplate: 'altLayout',
                        this.render('oldBrowser');
                        this.stop();
                    }
              },
          });
    
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-23
      • 2013-10-27
      • 2019-03-01
      • 1970-01-01
      • 2014-03-31
      • 1970-01-01
      • 2014-05-19
      • 1970-01-01
      相关资源
      最近更新 更多