项目代码:https://github.com/newcomein/Wakeup-OS/tree/master/app/controller/post.js 直接打开https://github.com/newcomein/Wakeup-OS/tree/master/app/view/default/pc/index.html 点击上传文件,即可重现这个问题
问题代码:
const hash = crypto.createHash('sha512'); files2.on('data', (data) => { hash.update(data); }); files2.on('end', (data) => { var a = hash.digest('hex'); console.log(a); }); console.log(a);
第二个console.log(a) 报错信息:a is not defined 请问end里面定义的变量也会被消费掉?
因为我想要让外部读取流文件'end'事件中获取到的hex值,然而发现只能在内部读取 这样很不方便我做其他的操作,请问有什么方法把里面的变量暴露出来?
回复 (2)
N
刚发这个贴没多久我我突然想起来 我怎么不会用传参的方式.......fuck......竟然忘了这么重要的东西.......
Z
参与回复
登录后即可参与回复。登录