2017-03-09 76 views
0

我要顯示一個名爲「家」與路徑「/」和「/家」,但我的代碼它不工作模板如何在多個Ironrouter路徑中使用一個模板?

/** Iron router config file **/ 
Router.configure({ 
    layoutTemplate: 'layout', 
    notFoundTemplate: '404', 
    loadingTemplate: 'loading', 
    fastRender: true, 
}); 

// Home 
Router.route('/', { 
    name: 'home', 
    waitOn: function() { 
    return [ 
     Meteor.subscribe('infosContainers'), 
     Meteor.subscribe('infosMachines'), 
     Meteor.subscribe('alertes'), 
    ]; 
    }, 
    fastRender: true, 
}); 

Router.route('/home', { 
    name: 'home', 
    waitOn: function() { 
    return [ 
     Meteor.subscribe('infosContainers'), 
     Meteor.subscribe('infosMachines'), 
     Meteor.subscribe('alertes'), 
    ]; 
    }, 
    fastRender: true, 
}); 

它不喜歡的事實模板「家「是在2路由(因爲如果我設置name: sokasok在第二個它的工作)

你能幫我嗎?

回答

0

'name'不適用於模板渲染,它是路由的名稱。您需要做的是撥打路線action中的this.render('home')

Router.route('/home', { 
    waitOn: function() { 
    return [ 
     Meteor.subscribe('infosContainers'), 
     Meteor.subscribe('infosMachines'), 
     Meteor.subscribe('alertes'), 
    ]; 
    }, 
    action: function(){ 
     this.render('home'); 
    } 
    fastRender: true, 
}); 
+0

huu我不清醒,謝謝! – Jerome

相關問題