Meteor에 로그인했는지 여부에 따라 레이아웃을 어떻게 결정합니까? 내가 사용자가 Meteor로 로그인했는지 확인하십시오.
Router.map(function() {
this.configure({
layoutTemplate: Meteor.userId() ? "appLayout" : "startLayout",
});
});
을 시도
나는 오류가 Meteor.user()
언급 한 바와 같이 당신이 사용자로부터 데이터를 필요로하는 경우, 그렇지 않으면 Meteor.users.findOne({_id: this.userId})
를 사용, 기능에서 사용할 수있는, 당신은 this.userId
을 사용할 수 있습니다
Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
'this.userId'는 로그인되어 있어도'undefined'입니다. 내 맵핑 또는 사용되지 않는 경로 구조입니까? http://eventedmind.github.io/ironrouter/#creating-route-controllers에 따르면 구조는 여전히 사용됩니다. 다른 구조를 사용하는 경우 각 경로의 이름을 지정하는 방법을 모르겠습니다. – Jamgreen
컨트롤러는 동일하게 유지되지만 더 이상지도 기능이 없으며 해당 기능에 대해서는 전혀 알지 못합니다 (waitOn 등), http://eventedmind.github.io/iron-router/#route-parameters 각 경로를 작성하기 위해 http://eventedmind.github.io/ironrouter/#named-routes를 지정하십시오. – Sindis
this.userId 라우트가 Meteor.user() 오브젝트보다 먼저 작성되기 때문에 정의되어 있지 않아야합니다. 따라서 this.userId는 다음과 같습니다. 페이지가로드되기 전에 호출됩니다. 어쩌면 그것을 함수로 묶어보세요. – Sindis