Last active
November 29, 2018 08:38
-
-
Save lichspace/fe6170d892d17ac2ac354c9bb1661b5e to your computer and use it in GitHub Desktop.
react upload preview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| handleChange(e){ | |
| console.log('file',e.target.files) | |
| let files = [...e.target.files] | |
| let that = this | |
| let fileList = [] | |
| files.map((v,n)=>{ | |
| let reader = new FileReader(e); | |
| reader.onload = function () { | |
| let url = event.target.result | |
| fileList.push({ | |
| originFile:v, | |
| url:url||'' | |
| }) | |
| if(fileList.length===files.length){ | |
| that.setState({ | |
| fileList | |
| }) | |
| } | |
| } | |
| reader.readAsDataURL(v); | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment