2015-05-15 20 views
0

我剛開始使用iron:router包。這是我的項目文件:爲什麼在渲染模板之後到家的路線改變?

路由器example.js

if (Meteor.isClient) { 
    //some code 
    } 
    if (Meteor.isServer) { 
    //some code 
    } 
    Router.route('/', function(){ 
     this.render('Home'); 
    }); 
    Router.route('/hello', function(){ 
     this.render('hello'); 
    }); 
    Router.route('/items', function(){ 
     this.render('Items'); 
    }); 
    Router.route('/serverItem', function(){ 
     var req = this.request; 
     var res = this.response; 
     res.end('Hello from the server\n'); 
    }, {where: 'server'}); 

路由器example.html的

<body> 
<h1>Welcome to Meteor!</h1> 
<ol> 
    <li><a href="{{pathFor '/'}}">This routing doesn't work</a></li> 
    <li><a href="{{pathFor 'hello'}}">Hello Template</a></li> 
    <li><a href="{{pathFor 'items'}}">Items Template</a></li> 
    <li><a href="{{pathFor 'serverItem'}}">Server Item</a></li> 
    <li><a href="http://localhost:3000/">Hard link works</a></li> 
</ol> 
</body> 

templates.html

<template name = "Home"> 
<h2>Default: '/' brings you here</h2> 
<p>This is the home template</p> 
</template> 

<template name = "Items"> 
<h2>This is the items template. Items Page linked using pathFor helper</h2> 
</template> 

<template name="hello"> 
<button>Click Me</button> 
<p>You've pressed the button {{counter}} times.</p> 
</template> 

因此,在主頁「 localhost:3000「,默認情況下呈現」主頁「模板,如預期的那樣。一旦我點擊其他鏈接: 你好模板, 項目模板等 這些渲染,但使用{{pathFor'/'}}輔助指定的主鏈接停止工作,我必須使用硬鏈接(本地主機: 3000)返回主頁。將鼠標懸停在該鏈接上表明它指向不同的路線。

那麼我在這裏做錯了什麼?

回答