mirror of
https://gitee.com/newgateway/vtj.git
synced 2026-06-07 23:15:26 +08:00
docs: ✏️ utils
This commit is contained in:
BIN
docs/src/examples/utils/download/background.jpg
Normal file
BIN
docs/src/examples/utils/download/background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 346 KiB |
59
docs/src/examples/utils/download/download.vue
Normal file
59
docs/src/examples/utils/download/download.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div>
|
||||
<XAction
|
||||
label="downloadUrl"
|
||||
type="primary"
|
||||
@click="onDownloadUrl"></XAction>
|
||||
|
||||
<XAction
|
||||
label="downloadBlob"
|
||||
type="primary"
|
||||
@click="onDownloadBlob"></XAction>
|
||||
|
||||
<XAction
|
||||
label="downloadRemoteFile"
|
||||
type="primary"
|
||||
@click="onDownloadRemoteFile"></XAction>
|
||||
|
||||
<XAction
|
||||
label="downloadJson"
|
||||
type="primary"
|
||||
@click="onDownloadJson"></XAction>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { XAction } from '@vtj/ui';
|
||||
|
||||
import {
|
||||
downloadUrl,
|
||||
downloadBlob,
|
||||
downloadRemoteFile,
|
||||
downloadJson
|
||||
} from '@vtj/utils';
|
||||
|
||||
import { fileToBase64 } from '@vtj/utils';
|
||||
|
||||
const onDownloadUrl = () => {
|
||||
downloadUrl(
|
||||
'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
|
||||
'elementUI.jpeg'
|
||||
);
|
||||
};
|
||||
|
||||
const onDownloadBlob = async () => {
|
||||
const blobParts = ['<q id="a"><span id="b">hey!</span></q>']; // 一个包含单个字符串的数组
|
||||
const blob = new Blob(blobParts, { type: 'text/html' }); // 得到 blob
|
||||
downloadBlob(blob);
|
||||
};
|
||||
|
||||
const onDownloadRemoteFile = async () => {
|
||||
downloadRemoteFile('./background.jpg', 'background.jpg', 'image/jpg');
|
||||
};
|
||||
|
||||
const onDownloadJson = () => {
|
||||
downloadJson('{name:"aa",age:"22"}', 'a.json');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user