kui-vue
Version:
A lightweight desktop UI component library suitable for Vue.js 2.
48 lines (46 loc) • 964 B
Markdown
<cn>
### 照片墙
设置 type = 'picture',用户可以上传图片并在列表中显示缩略图
</cn>
```vue
<template>
<Upload
action="https://www.chuchur.com/api/upload/image"
name="file"
type="picture"
:headers="headers"
@change="handleChange"
:fileList="fileList"
accept="image/*"
uploadText="上传图片"
>
</Upload>
</template>
<script setup>
import { ref } from "vue";
const headers = ref({
authorization: "here is token",
});
const fileList = ref([
{
url: "https://cdn.chuchur.com/upload/demo/test_300.jpg",
status: "uploading",
filename: "test.jpg",
size: "222kb",
percent: 50,
status: "uploading",
},
{
url: "https://cdn.chuchur.com/upload/demo/test_300.jpg",
status: "error",
filename: "test.jpg",
size: "222kb",
},
]);
const handleChange = (info) => {
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
};
</script>
```