【问题标题】:Meteor FlowRouter getParam errorMeteor FlowRouter getParam错误
【发布时间】:2016-02-27 13:01:31
【问题描述】:

我有一个重置密码的方法,设置如下:

FlowRouter.route('/reset-password/:token',{
    name:'reset-password',
    action(){
        BlazeLayout.render('MainFullLayout',{main:'ResetPassword'});
    }
});

所以当我想访问它时,我可以:

var tokenVar = FlowRouter.getParam("token");

但是当我在Accounts.resetPassword() 中使用它时:

Template.ResetPassword.events({
    'submit #resetpassword-form': function(event){
        event.preventDefault();
        var newPasswordVar = event.target.resetNewPassword.value;
        var tokenVar = FlowRouter.getParam("token");
        Accounts.resetPassword({
            token: tokenVar,
            password: newPasswordVar
        });
    }
  });

我遇到了一个错误:

未捕获的错误:匹配错误:预期的字符串,得到对象

我该如何解决这个问题?

【问题讨论】:

    标签: meteor meteor-accounts flow-router


    【解决方案1】:

    对resetPassword 的调用应如下所示:

    Accounts.resetPassword(tokenVar, newPasswordVar);
    

    【讨论】:

    • 我使用你的方法遇到另一个错误:Unexpected type cast (33:12).
    • 我让它工作了。发生的事情是我取出了{},但仍然使用对象方式:Accounts.resetPassword( **token:** tokenVar, **password:** newPasswordVar)。把它拿出来,一切都会好起来的。
    猜你喜欢
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    • 2016-08-20
    相关资源
    最近更新 更多