84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
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