0
내 문제는 두 개의 유사한 경로가 있으며 첫 번째 라우터가 내 구독을 기다리고 전체 템플릿을 렌더링하지만 두 번째 것은 즉시로드가없고 렌더링 된 데이터가 오류를 일으키는 것입니다. (아직 구독 된 컬렉션이 없기 때문에). 여기에 제 코드를 붙여 넣습니다. 템플릿과 데이터가 전달 되었기 때문에 두 번째 코드는 다릅니다.하지만 나머지 코드는 실제로 동일합니다. 철분 라우팅으로 시작한 것일까 요, 누군가 실수가 어디인지 말할 수 있을까요?라우터가 구독을 기다리지 않습니다.
Router.map(function() {
this.route('/', {
onBeforeAction: function() {
if (Meteor.user()) {
if (Meteor.user().firstLogin)
this.render("firstLogin");
else
Router.go('/news');
} else {
this.render("start");
}
},
waitOn: function() {
return Meteor.subscribe('allUsers');
},
onAfterAction: function() {
document.title = "someTitle";
},
loadingTemplate: "loading",
});
this.route('users',{
path:'/user/:_id',
layoutTemplate: 'secondLayout',
yieldTemplates: {
'template1': {to: 'center' },
'template2': {to: 'top' },
'template3': {to: 'left' },
'template4': {to: 'right' },
},
waitOn: function(){
return Meteor.subscribe("allUsers");
},
data: function(){
return Meteor.users.findOne({_id:String(this.params._id)});
},
loadingTemplate: "loading",
});
});