-1
for (var i=0; i<10; i++) {
this.videos[i].url = 'http://localhost:27017/' +
this.videos[i].url;
this.videos[i].avgRating = 0;
for(var j=0;j<this.videos[i].rating.length;j++){
this.videos[i].avgRating += this.videos[i].rating[j];
}
第二個for循環導致的錯誤「無法獲取的未定義或爲空引用屬性‘長’」for循環不會在Javascript妥善拿起數組長度
'this.videos [i] .rating' is undefined –
can you console.log(this.videos [i] .rating)並查看該值是否存在 – marvel308
您應該使用'i
Phix