简单的演示
let inp = document.querySelector('input')
let img = document.querySelector('img')
inp.addEventListener('change',function(e){
let file = e.target.files[0]
if(file){
let reader = new FileReader()
reader.onload = function(e){
img.setAttribute('src',e.target.result)
}
reader.readAsDataURL(file)
}
})