fix: 修复upload组件中事件拿到files为空的bug

This commit is contained in:
wanchun 2021-05-23 10:51:31 +08:00
parent 60e70f9ea4
commit fd64419b6e
3 changed files with 11 additions and 9 deletions

View File

@ -8,7 +8,7 @@
<Row class="panel">
<Cell class="son-panel" span="12">
<div class="panel-case">
<Upload v-for="(item, index) in data" :max-size="10" :key="index" :accept="option.accept" :action="action">
<Upload v-for="(item, index) in data" url="test" @on-fail="fail" :max-size="10" :key="index" :accept="option.accept" >
<!-- <Wb-button>点击上传{{ item.url }}</Wb-button> -->
</Upload>
</div>
@ -133,11 +133,11 @@ export default {
},
methods: {
sucess(file, result, arg) {
},
fail() {
console.log(arguments)
fail(files, status) {
console.log(files)
}
}
}
</script>
</script>

View File

@ -1,6 +1,6 @@
{
"name": "@webank/fes-ui",
"version": "0.4.9",
"version": "0.4.10",
"description": "基于Vue2.0适用于PC管理端的组件库",
"main": "dist/fes-ui.js",
"scripts": {

View File

@ -133,8 +133,10 @@ export default {
const files = e.target.files;
const len = files.length;
const validateArray = [];
const validateFiles = [];
for (let i = 0; i < len; i++) {
const file = e.target.files[i];
validateFiles.push(file);
validateArray.push(this.validate(file));
}
Promise.all(validateArray).then(
@ -159,12 +161,12 @@ export default {
) {
try {
const result = JSON.parse(xhr.responseText);
this.$emit('on-success', files, result);
this.$emit('on-success', validateFiles, result);
} catch (e1) {
console.error('响应格式不正确');
}
} else {
this.$emit('on-fail', files, xhr.status);
this.$emit('on-fail', validateFiles, xhr.status);
}
this.$refs.input.value = '';
}
@ -179,7 +181,7 @@ export default {
if (this.action) {
this.action(false);
} else {
this.$emit('on-fail', files, -1);
this.$emit('on-fail', validateFiles, -1);
}
}
);