代码如下:<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title></head><body> <input type="file" onchange='fileChoosed(event)'> <img id='a'> <script> function fileChoosed(event) { console.log('aa'); let file = event.target.files[0], fileName = file.name, img = document.getElementById('a'), fr = new FileReader(), ts = this; fr.addEventListener("load", () => { let blob = 'a'; console.log(fileName, img, blob); //这里能获取到三个变量 img.onload = (img, blob, fileName) => { debugger; view.insertPicture(img, blob, fileName); //这里就获取不到了 }; img.src = fr.result; }); fr.readAsDataURL(file); } </script></body></html>找了半天没找到原因,求帮助
添加回答
举报
0/150
提交
取消