我剛更新到流星1.0和最新版本的鐵路由器。爲什麼我無法將數據傳遞給Iron-Router路由模板?
無論出於何種原因,當我將數據傳遞給僅包含單個文檔的模板時,它就可以工作。但是當我嘗試將多個文檔傳遞給模板時,我得到一個空白屏幕。
//galleryRoute.js
Router.route('/:section', function() {
this.layout('Gallery', {
data: function() {
var data = { photos: photos.find({ path: { $regex: '/'+this.params.section +'/' } }) };
return data;
}
});
});
<template name="Gallery">
<div class="container">
{{#each photos}}
<div class="section-photo" style="background:url({{path}}) no-repeat center center; width:175px; height:175px; background-size:cover;"></div>
{{/each}}
</div>
</template>
想知道如果任何人有關於爲什麼這會是什麼想法?
你的'.find()'返回任何東西嗎?嘗試獲取'.find()'的結果並記錄結果。 – 2014-11-02 05:52:09
可能的重複: http://stackoverflow.com/questions/30824800/meteor-data-passed-to-template-from-iron-router-is-empty-at-first-load – 2015-06-14 11:40:33