P5 javascript LoadJSON 数据来晚了
P5 javascript LoadJSON Data is to late
我试图从 p5 读取带有 loadJSON 的 Json 文件,但数据来晚了。如果我尝试 console.log(JSON.stringify(data))
它说 {}
.
function setup() {
for(i = 0;i <= 3;i++) {
//load the JSON
data = loadJSON('test'+ i +'.json');
//Work with it
console.log(JSON.stringify(data);
}
}
function test(mynewdata) {
console.log(mynewdata);
}
data = loadJSON('test' + i + '.json',test);
这对我有用。谢谢!
我试图从 p5 读取带有 loadJSON 的 Json 文件,但数据来晚了。如果我尝试 console.log(JSON.stringify(data))
它说 {}
.
function setup() {
for(i = 0;i <= 3;i++) {
//load the JSON
data = loadJSON('test'+ i +'.json');
//Work with it
console.log(JSON.stringify(data);
}
}
function test(mynewdata) {
console.log(mynewdata);
}
data = loadJSON('test' + i + '.json',test);
这对我有用。谢谢!