【发布时间】:2015-06-14 19:35:24
【问题描述】:
我有这样的路线:
Router.route('/box', function () {
this.render('boxCanvasTpl');
},{
name: 'box',
layoutTemplate: 'appWrapperLoggedInTpl',
waitOn: function() {
console.log("Box route ran ok.");
return [
Meteor.subscribe('item_ownership_pub', function() {
console.log("subscription 'item_ownership_pub' is ready.");
}),
Meteor.subscribe('my_items', function() {
console.log("subscription 'my_items' is ready.");
})
];
}
});
...我正在单击模板中的链接,如下所示:
<a href="/box?box=123" class="box-num-items">My Link</a>
我收到“Box 路线运行正常”。消息,但由于某种原因页面无法导航到给定的 URL。我在渲染“boxCanvasTpl”时运行的函数中添加了 console.log 代码,但这些代码没有显示在浏览器控制台中。似乎中间有什么东西阻止了模板重新渲染,但我不能指望它 - 有什么想法吗?
【问题讨论】:
-
把
subscribe的两个回调都去掉了还能用吗? -
这很难测试,因为包含上述链接的页面是我试图导航到的页面。这会是问题吗,即如果我在 /box?box=111 上并尝试导航到 /box?box=123 - 是不是“onRendered”功能不会重新运行?
-
我对你在这里想要做什么感到有点困惑。您在 URL (
?box=123) 中有参数,但是您没有任何代码可以使用this.params- stackoverflow.com/questions/23050664/… 访问这些 URL 参数,是的,如果您在Template.boxCanvasTpl.onRendered()和它没有出现,这意味着模板没有被渲染(或重新渲染,在你的情况下)。哎呀,我讨厌讨厌讨厌 Stack Overflow cmets 中的格式...... -
@fuzzybabybunny 我在路由器之外使用 Router.current().params.query.box(在我的 Template.onRendered 函数中),但这与问题无关。
-
啊,但它是相关的,因为 onRendered() 没有触发,因此你的参数没有被识别。
标签: meteor iron-router