input change only trigger once bug
input change only trigger once bug
clear first
https://stackoverflow.com/a/11280934/5934465
upload Excel once bug
solution
uploadExcelFile() {
// $refs / $el
const file = document.querySelector(`[data-uid="input"]`);
const isBind = file.dataset.isBind || false;
log(`change 1`);
if(!isBind) {
// once
file.dataset.isBind = true;
file.addEventListener(`change`, () => {
log(`change ...`);
this.blob = file.files[0];
const {
name,
type,
size,
} = this.blob;
this.size = `文件大小: ` + size / 1000 + `KB`;
this.filename = `文件名: ` + name;
}, false);
file.addEventListener(`click`, () => {
log(`click `);
// clear
file.value = ``;
// e.target.value = '';
}, false);
}
file.click();
},
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12357840.html
未经授权禁止转载,违者必究!