我已经建立了这样的路线:流星路由器路由属性未定义
Meteor.Router.add({
'/:menuSlug': function(menuSlug) {
Template.menu.items = function() { return Items.find({menuId: Menus.findOne({slug: menuSlug})._id}); }
return 'menu';
}
});
然而,当我浏览到/我的测试段塞,我得到这个错误
Uncaught TypeError: Cannot read property '_id' of undefined
我想这与https://stackoverflow.com/a/14107148/979315有关,但由于我没有使用Meteor.user()被动收集,所以我不确定如何在数据正确提取后重新呈现这个页面。有什么想法吗?
你检查了menuSlug的内容吗? 或者它可能是菜单项不存在。 – 2013-05-10 09:44:04
菜单条目确实存在。在检索数据之前加载页面。 – 2013-05-10 18:22:16