Why iron-router does not render carousel?

2019-07-20 13:01发布

问题:

it works perfectly when I make it like this

<body>
{{> carousel}}
</body>
<Template name="carousel">
....here the code of carousel...
</Template>

but when I use iron-router to render the Template; it does not render carousel

<body>
{{rendreRouter}}
</body>
<Template name="carousel">
    ....here the code of carousel...
 </Template>

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

回答1:

I'm coming to the conclusion that the documentation you're reading is not in sync with the code base. In fact, it looks like the feature is gone.

In my own exploration of the topic, I have an alternate solution at that may work for you at the bottom of this post.



回答2:

Init your carousel in template.rendered hook, for example my template is named main_slider.

Template.main_slider.rendered = function() {
    // init carousel here
};