Today I find a bug which happened in Chrome but run well in Firefox. It's a upload component which like this:
<input type="file" v-on:change="upload($event)"/>
upload(e) {
this.name = e.target.files[0].name;
this.resultUrl = e.target.files[0];
}
I choose a file and then rechoose and cancel, I found the page is stopped. What's worse is that the console doesn't have any error messages. So I have to guess what caused the bug.
I used sometime and realized the error may in the component. So I add a print console.log(e.target.files)
in upload method. As I excepted, the Chrome's print is different with Firefox's print. Chrome has two print and Firefox just one. This is Chrome's print.
And then I found this input type=“file”, clearing file after clicking cancel in chrome. I have known what caused the bug and fixed it by adding a judge.
But this is not the first time I meet the page stopped with no error message on console. So how to throw and deal with the error happened in vue component?