ant-design-vue/components/upload/demo/basic.md

47 lines
1.0 KiB
Markdown
Raw Normal View History

2018-04-13 16:19:50 +08:00
<cn>
#### 点击上传
经典款式,用户点击按钮弹出文件选择框。
</cn>
<us>
#### Upload by clicking
Classic mode. File selection dialog pops up when upload button is clicked.
</us>
2019-10-09 18:32:23 +08:00
```tpl
2018-04-13 16:19:50 +08:00
<template>
2019-09-28 20:45:07 +08:00
<a-upload
name="file"
:multiple="true"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
:headers="headers"
@change="handleChange"
>
<a-button> <a-icon type="upload" /> Click to Upload </a-button>
2018-04-13 16:19:50 +08:00
</a-upload>
</template>
<script>
2019-09-28 20:45:07 +08:00
export default {
data() {
return {
headers: {
authorization: 'authorization-text',
},
};
2018-04-13 16:19:50 +08:00
},
2019-09-28 20:45:07 +08:00
methods: {
handleChange(info) {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
this.$message.success(`${info.file.name} file uploaded successfully`);
} else if (info.file.status === 'error') {
this.$message.error(`${info.file.name} file upload failed.`);
}
},
},
};
2018-04-13 16:19:50 +08:00
</script>
```