let files = e.target.files;localStorage.setItem('files',JSON.stringify(files));The storage result is: {"0":{}}How Solved, waiting online...
走同样的路,发现不同的人生
e.target.files is not an array, so it needs to be converted into an array.
e.target.files
Array.from
Each item of data is a File object. If you want to store the file name, you can take the name attribute.
The code is probably like this:
let files = Array.from(e.target.files).map(x => x.name); localStorage.setItem('files',JSON.stringify(files));
or
let files = [...e.target.files].map(x => x.name); localStorage.setItem('files',JSON.stringify(files));
e.target.files
is not an array, so it needs to be converted into an array.Each item of data is a File object. If you want to store the file name, you can take the name attribute.
The code is probably like this:
or