Meteor - 替代布局模板
Meteor - alternative layout template
我有布局模板,但想应用替代布局模板。我已经创建了 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();
}
},
});
});
以下对我有用:
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();
}
},
});
});
我有布局模板,但想应用替代布局模板。我已经创建了 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();
}
},
});
});
以下对我有用:
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();
}
},
});
});