因此,使用papa解析,我将文件解析为本地CSV文件。因此,当我将更新的对象打印到控制台时,我将获得该对象以根据某些条件应用的更改后的值返回。我的问题是获取图像尺寸:宽度和高度。
var w;
var h;
let testString = "s2345232";
if (/^[s]\d+$/.test(testString) == true) {
url = baseUrl + testString + suffix;
getMeta(url, function (width, height) {
w = width;
h = height;
console.log(w, h); //works
});
}
console.log(w, h); //doesn't work
//Here is the function to retrieve the image data
function getMeta(url, callback) {
var img = new Image();
img.src = url;
img.addEventListener("load", function () {
callback(this.naturalWidth, this.naturalHeight);
});
};