我已經建立了這樣的路線:流星路由器路由屬性未定義
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