【发布时间】:2016-10-08 23:20:53
【问题描述】:
大家好,我在我的项目中使用Collection2,我想获取一个字段的长度,该字段的类型为:来自另一个字段的数组
这是我的代码示例
yes: {
type: Array,
optional: true
},
"yes.$": {
type: Object
},
yesLength: {
type: Number,
autoValue: function(){
var lenYes = this.field("yes").length;
console.log(this.field("yes"));
console.log(lenYes)
return lenYes;
},
optional: false
},
当我将 this.field("yes") 记录到控制台时,它看起来很好,但是当我记录 lenYes 即 this.field("yes").length 时,我得到了未定义。我在这里做错了吗?谢谢
【问题讨论】:
标签: mongodb meteor collections meteor-collection2