【发布时间】:2015-02-27 01:40:42
【问题描述】:
这段代码很好用
{
action: function() {
this.render('userprofile');
},
onBeforeAction: function() {
this.redirect('/mypage');
}
});
但是没有
{
action: function() {
this.render('userprofile');
},
onBeforeAction: function() {
if (Meteor.user().profile.uname == this.params.uname) {
this.redirect('/mypage');
this.stop();
} else {
this.next()
}
}
});
和
if (Meteor.user().profile.uname == this.params.uname) {
this.redirect('/mypage')
} else {
this.next()
}
如果你输入不正确的uname这个条件有效
} else {
this.next()
}
如果是真的
if (Meteor.user().profile.uname == this.params.uname) {
this.redirect('/mypage');
this.stop();
}
页面仅将链接从 /StevePi(正确的 unname)更改为 /mypage,但不渲染
我尝试使用Router.go()和其他方法,但没有帮助:(
【问题讨论】:
-
为什么要调用 this.stop()?另外,您是否在验证 Meteor.user().profile.uname 实际上是在调用什么东西?您是否收到任何控制台错误?
标签: meteor iron-router