gpt4 book ai didi

javascript - 为什么 Meteor.users.findOne({username : "test"}) returns an object but replacing "test" with variable that has the same value returns undefined

转载 作者:行者123 更新时间:2023-11-30 12:29:39 31 4
gpt4 key购买 nike

var usr = [];
var chatUsers = Session.get("newChatUser");
for ( i in chatUsers )
{
var a = chatUsers[i];
var id = Meteor.users.findOne({ username : a });
usr.push({
uid : id._id,
name : a
});
}

当 a 是“测试”但当我运行时,这里的 id 变为未定义

Meteor.users.findOne({ username : "test" })

在浏览器控制台中,它返回正确的对象。我的代码有什么问题?

最佳答案

尝试:

Meteor.users.findOne({ username: a.trim() })

关于javascript - 为什么 Meteor.users.findOne({username : "test"}) returns an object but replacing "test" with variable that has the same value returns undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28135409/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com