2016-04-16 74 views
0

我想在我的流星應用上有多個頁面,我正在運行流星1.3.1和最新的鐵路由器。鐵路由器只能用於一條路由

這是我的main.js文件。

Router.route('/home', function() { 
    this.render('home'); 
}); 
Router.route('/register', function() { 
    this.render('register'); 
}); 

這是我的main.html中文件

<template name="home"> 
    <h1>Hello there !</h1> 
</template> 
<template name="about"> 
    <h1>this is an about page!</h1> 
</template> 
<template name="register"> 
    <h2>Register</h2> 
</template> 

現在,如果我瀏覽到http://localhost:3000/home我可以看到hello there!

但如果我瀏覽到http://localhost:3000/register我看到 Oops, looks like there's no route on the client or the server for url: "http://localhost:3000/register."

然而如果我將js文件中路由的位置切換到:

Router.route('/register', function() { 
    this.render('register'); 
}); 
Router.route('/home', function() { 
    this.render('home'); 
}); 

然後註冊頁面的作品和主頁沒有。

回答

0

嘗試Router.map語法來代替:

Router.map(function() { 
    this.route('home', {path: '/home',}); 
    this.route('register', {path: '/register',}); 
}); 
0

所以事實證明,因爲我用Chrome Canary版(鍍鉻的實驗版),在使用谷歌瀏覽它好工作就沒有工作。