tiny-vue_version0/examples/sites/demos/pc/app/file-upload/upload-request-composition-...

38 lines
925 B
Vue

<template>
<tiny-file-upload
ref="uploadRef"
:action="action"
:file-list="fileList"
with-credentials
:headers="headers"
:before-upload="beforeUpload"
>
<template #trigger>
<tiny-button type="primary">选取文件</tiny-button>
</template>
</tiny-file-upload>
</template>
<script setup>
import { ref } from 'vue'
import { FileUpload as TinyFileUpload, Button as TinyButton, Modal } from '@opentiny/vue'
const action = ref('http://localhost:3000/api/upload')
const fileList = ref([
{
name: 'test1',
url: `${import.meta.env.VITE_APP_BUILD_BASE_URL}static/images/fruit.jpg`
}
])
const headers = ref({
'Accept-Language': 'en,zh',
Authorization: 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
})
function beforeUpload() {
Modal.message({ message: '查看请求头示例请打开浏览器开发者工具 network 的 upload 请求', status: 'info' })
return true
}
</script>