-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 受控使用 | ||
en: Controlled usage | ||
order: 0 | ||
--- | ||
|
||
## zh | ||
|
||
`files` 支持受控,添加文件到 `files` 中可自动上传文件,删除则可以自动终止上传。 | ||
|
||
## en | ||
|
||
`files` supports controlled usage, file is auto uploaded after added to `files`, and aborts after removed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<template> | ||
<IxUpload v-model:files="files" action="https://run.mocky.io/v3/7564bc4f-780e-43f7-bc58-467959ae3354"> | ||
<IxButton>Upload</IxButton> | ||
<template #list> | ||
<IxUploadFiles type="text" /> | ||
</template> | ||
</IxUpload> | ||
<IxButton @click="addFile">addFile</IxButton> | ||
<IxButton @click="clearFiles">clearFiles</IxButton> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { UploadFile } from '@idux/components/upload' | ||
import { ref } from 'vue' | ||
const files = ref<UploadFile[]>([]) | ||
let keySeed = 0 | ||
const addFile = () => { | ||
const newFile = new File( | ||
[ | ||
new Blob([ | ||
Array.from(new Array(100)) | ||
.map(() => 'file content') | ||
.join('\n'), | ||
]), | ||
], | ||
'new_File', | ||
{ | ||
type: 'text/plain', | ||
}, | ||
) | ||
files.value.push({ | ||
key: `newFile-${keySeed++}`, | ||
raw: newFile, | ||
name: newFile.name, | ||
status: 'selected', | ||
}) | ||
} | ||
const clearFiles = () => { | ||
files.value = [] | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters