困惑关于Meteor this.next()错误onBeforeAction

时间:2015-07-20 22:36:12

标签: javascript meteor iron-router

我有一个路由器地图的代码:

this.route('confirmTag', {
    path: '/confirm-tag',
    template: 'confirmTag',
    controller: 'SignUpController',
    onBeforeAction: function () {
        if (Meteor.user()) {
            if (typeof user.profile.tag === 'undefined') {
                Router.go('confirm');
            } else {
                Router.go('checkEmail');
            }
            this.next();
        } else {
            Router.go('signUp');
        }
        this.next();
    }
});

然而,我一直在控制台中收到此错误:

Exception in callback of async function:
.onBeforeAction@http://localhost:3000/lib/router.js?783dc96a24a92cfd09fbf0ca371d762661a830bb:87:9

示例代码中的第87行是:

if (typeof user.profile.tag === 'undefined') {

该怎样或应该如何" this.next();"被放在上面的代码中?

提前致谢。

1 个答案:

答案 0 :(得分:1)

我没有在任何地方看到user。怎么样......

this.route('confirmTag', {
    path: '/confirm-tag',
    template: 'confirmTag',
    controller: 'SignUpController',
    onBeforeAction: function () {
        if (Meteor.user()) {
            var user = Meteor.user();
            if (typeof user.profile.tag === 'undefined') {
                Router.go('confirm');
            } else {
                Router.go('checkEmail');
            }
            this.next();
        } else {
            Router.go('signUp');
        }
        this.next();
    }
});
相关问题