为什么Meteor.Accounts会返回;没有方法';onCreateUser'&引用;?
我试图在创建用户配置文件时将accountActive和accountExpirationDate添加到用户配置文件中。根据我读到的所有内容,我应该使用Accounts.onCreateUser,如下所示:为什么Meteor.Accounts会返回;没有方法';onCreateUser'&引用;?,meteor,account,Meteor,Account,我试图在创建用户配置文件时将accountActive和accountExpirationDate添加到用户配置文件中。根据我读到的所有内容,我应该使用Accounts.onCreateUser,如下所示: // Add accountActive and accountExpirationDate Accounts.onCreateUser(function(options, user) { if (options.profile) { user.profile = options
// Add accountActive and accountExpirationDate
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
user.profile = options.profile;
user.profile.accountActive = false;
user.profile.accountExpirationDate = null;
}
return user;
});
这两个字段没有被添加,我在控制台中收到这个错误
Uncaught TypeError: Object #<Object> has no method 'onCreateUser'
uncaughttypeerror:对象#没有方法“onCreateUser”
我做错了什么?问题是Accounts.onCreateUser正在客户端文件夹中运行。它不能在客户端运行,只能在服务器上运行。它是否在客户端上运行?该功能仅在服务器上。通过将代码放入项目的
/server
子目录中的文件,可以确保代码仅在服务器上加载。@user728291回答此问题。这就解决了问题。我在client文件夹中使用了config.js。我不小心在lib文件夹中使用了它,但仍然抛出了一个错误(因为lib既是client又是server,obvs)-将其移动到server文件夹,然后将其放到presto。