Meteor cursor.fetch().property returns "undefined"
Meteor cursor.fetch().property returns "undefined"
我有一个简单的助手,可以将数组返回到模板中的 #each 块。这工作正常,并且显示标签。
但是,我不明白为什么我不能控制台.log用户标签的属性,例如userTags.BusinessContact。但是我可以控制台.log完整的对象,因此(控制台.log(用户标签))将起作用。
Template.profileTags.helpers({
tag:function(){
var userTags = tikiUser.find({}).fetch()
//this returns "undefined" 2 times
Meteor.setTimeout(function(){console.log(userTags.BusinessContact)}, 500)
return userTags
}
})
为什么?
感谢
您正在尝试获取数组的 BusinessContact 属性 - 尝试执行
userTags[0].BusinessContact
PS:发布问题时尝试 meteorpad.com
试试这个。
if(userTags)
{
Console.log(userTags.BusinessContact)
}
在 meteor 中,有些时候我们不会第一次得到值,所以,如果我们写一个 if 条件,那么它只会检查那里的值。
希望这对你有帮助。
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 铬:“;未捕获的语法错误:意外的标记:"
- /undefined在我的404错误日志中多次出现
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- RequireJS向模块传递配置总是返回undefined
- JSON数组数据返回Undefined
- 使用“+="操作人员
- TypeError:undefined不是一个对象(正在评估'msg.innerHTML="Uploa
- 神秘的"undefined不是函数”;
- 为什么"undefined为null或不是对象”;
- 在JSON中POST一个js::数组,得到"undefined:undefined”;
- new Parse.View and get"TypeError:undefined不是函数;
- 使用“webmethod”调用c#方法返回“undefined"
- 为什么“typeof false || undefined”返回"布尔值”;
- js未捕获类型错误:Cannot set property 'zIndex'undefined"
- 无法读取undefined"的属性0;在webgl应用中
- .wait()"undefined不是函数"
- document.log():"undefined不是函数”;