我想从json文件读取并使用它的值绘制三角形。在日常工作中,我可以将价值打印出来,除此之外,它将不再起作用。我的代码:未定义数组值
faces=new Array(40000);
$.getJSON('file.json', function(data) {
$.each(data.faces, function(i, f) {
faces[i]=new Array(3);
faces[i][1]=data.faces[i].f1;
faces[i][2]=data.faces[i].f2;
faces[i][3]=data.faces[i].f3;
//alert(faces[1][1]); works here
});
});
//alert(faces[1][1]); doesn't work here, console says faces[1][1] is undefined
我该如何解决这个问题?
data.faces什么是错在它ü需要使用的每个函数内部data.faces因为ü已经分配了各指标在变量f中 –