<input type="file" ref="upload" name="avatar" id='upload_input' accept="image/jpg" @change="upload($event)"/>
upload(e){
var image = e.target.files[0];
var uploadForm = new FormData();
var author = this.$route.params.userMessage.username
uploadForm.append('avatar', image, author);
this.$axios.post('http://localhost/users/upload',{uploadForm})
.then(function(res){
// console.log(res);
alert(res);
})
}
今天遇到一个奇怪的问题,上面是input标签和change事件的代码,一旦触发,浏览器控制台报错
Cannot read property 'target' of undefined
即事件里面的e.target.files[0]的target未定义,求大神解答。。