templat
<input type="file" :id="id" name="image" class="getImgUrl_file" @change="preview($event)">
srcipt
preview(event){
let files = document.getElementById(this.id).files[0]
this.imgDataUrl =this.getObjectURL(files)
this.$emit('sendImgUrl',this.imgDataUrl,this.id)
},
getObjectURL (file) {
let url = null ;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(file) ;
}else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) ;
}
return url ;
},