简体   繁体   English

为什么Iron-router无法呈现正确的帖子

[英]Why Iron-router does not render the correct post

Good morning / after noon. 早上好/中午之后。

this my project built with Meteor js. 这是我用Meteor js构建的项目。

I've this template(lien) for links 我有这个模板(留置权)用于链接

<template name="lien">
      <ul>
        <il><a href="{{pathFor 'dogo'}}">{{sousplus}}</a></il>
     </ul>
</template>

And another tempalte (dogo) for the post matching each link of the template above 另一个tempalte(dogo)用于匹配上面模板的每个链接的帖子

<template name="dogo">
<div class="container">
{{#if hadanata3ou}}
<button type="button" class="btn btn-default bttn"> ♥ </button>
{{/if}} 
<div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <h3 id="tex"> {{submittedText}}</h3>
    </div>
 </div>
</div>

<div class="container-fluid lov">
<div class="row">
 {{#each positions}}
  {{> position}}
  {{/each}}
   </div>   
   </div>
</template>

both templates are in the same template(home) side by side 两个模板并排在同一个模板中

<template name="home">
<div class="container">
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 ">

<div class="row">
        <div class="col-xs-1 col-sm-1 col-md-1 col-lg-1">
         <a href="#" id="plus" class="moumi"> + </a>
        </div>
        <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
         <h5> create a new categorie</h5>
        </div>
    </div>
    <div class="row">
      {{#each liens}}
        {{> lien}}
      {{/each}}
    </div>

</div>  

<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 ">


   {{> dogo}}

  </div>
 </div>
</div>
</template>

The goal is to render one and one specific template whenever a user click on one link from the template (lien); 目标是每当用户单击模板(留置权)中的一个链接时,就渲染一个和一个特定的模板。 knowing that there are several links matching several template (dogo); 知道有几个链接匹配多个模板(dogo);

The deal with me is that the template rendered is the same whatever the link clicked. 我要解决的是无论链接单击什么,呈现的模板都是相同的。

And here is my Iron-router configuration 这是我的Iron-router配置

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

Router.route('/posts/:_id', {
name: 'dogo',
data: function() { return Positions.findOne(this.params._id); }
});

Did I miss something? 我错过了什么? beacause it does not work with me. 因为它对我不起作用。 Could you enlighten me, please? 你能开导我吗?

The concept of operation is the same as todos which the link is here a link . 操作的概念与待办事项相同,这里的链接就是链接 Thank's 谢谢

If I'm not wrong, 如果我没看错

If you click on this 如果你点击这个

<li><a href="{{pathFor 'dogo'}}">{{sousplus}}</a></ll>

you want to redirect to /posts/:id 您想重定向到/posts/:id

then try 然后尝试

<li><a href="{{pathFor 'dogo' data=_id}}">{{sousplus}}</a></ll>

_id is to which route you want to redirect to

Refer to the docs: https://github.com/EventedMind/iron-router/blob/devel/Guide.md#path-and-link-template-helpers 参考文档: https : //github.com/EventedMind/iron-router/blob/devel/Guide.md#path-and-link-template-helpers

OR 要么

you could simply give 你可以简单地给

<li><a href="/posts/{{_id}}">{{sousplus}}</a></ll>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM