-
Notifications
You must be signed in to change notification settings - Fork 273
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
3 changed files
with
35 additions
and
11 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
13 changes: 8 additions & 5 deletions
13
examples/sites/demos/pc/app/file-upload/http-request-composition-api.vue
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 |
---|---|---|
@@ -1,23 +1,26 @@ | ||
<template> | ||
<tiny-file-upload ref="uploadRef" :http-request="httpRequest" :file-list="fileList"> | ||
<tiny-file-upload ref="uploadRef" :http-request="httpRequest" :file-list="fileList" @success="handleSuccess"> | ||
<template #trigger> | ||
<tiny-button>点击上传</tiny-button> | ||
</template> | ||
</tiny-file-upload> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, reactive } from 'vue' | ||
import { reactive } from 'vue' | ||
import { TinyFileUpload, TinyButton, TinyModal } from '@opentiny/vue' | ||
const fileList = reactive([]) | ||
const httpRequest = ref((files) => { | ||
const httpRequest = reactive(({ onSuccess, file }) => { | ||
return new Promise((resolve) => { | ||
// 此处为用户自定义的上传服务请求 | ||
setTimeout(() => { | ||
TinyModal.message('上传成功') | ||
fileList.push(files.file) | ||
onSuccess('上传成功') | ||
this.fileList.push(file) | ||
}, 500) | ||
}) | ||
}) | ||
const handleSuccess = (res) => { | ||
TinyModal.message(res) | ||
} | ||
</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