for(var i =0; i < e.target.files.length; i++){var freader =newFileReader(); freader.readAsDataURL(file);console.log(e.target.files);// ok freader.onload=(fe)=>{console.log(e.target.files);// error!};}
循着控制台的提示查了官档:
The SyntheticEvent is pooled. This means that the SyntheticEvent object will be reused and all properties will be nullified after the event callback has been invoked. This is for performance reasons. such, you cannot access the event in an asynchronous way.
SyntheticEvent 是合并而来。这意味着 SyntheticEvent 对象可能会被重用,而且在事件回调函数被调用后,所有的属性都会无效。出于性能考虑,你不能通过异步访问事件。
这下就明白了,只要在回调函数之前用变量保存事件属性就可以在回调里使用了
忽略隐式类型转换而浪费大把时间
开发设置页面时,列表组件会返回选中项目的下标,而设置业务函数没有值传入就会退出。
if(!name ||!value)return originSetting;
这样写的话,如果 value 为 0 也会退出...
解决方案
if(!name ||(!value && value !==0))return originSetting;