useDownloadFile
Introduction
下载在线链接资源文件
Basic Usage
ts
import { useDownloadFile } from '@flypeng/tool/browser';
Online Demo
useDownloadFile
<script lang="ts" setup>
import { useDownloadFile } from '@flypeng/tool/browser';
const downloadFile = () => {
useDownloadFile('https://flingyp.github.io/flypeng-tool/favicon.png', '@flypeng-tool.png');
};
</script>
<template>
<button @click="downloadFile">点击下载</button>
</template>
<style scoped>
button {
width: 80px;
border-radius: 4px;
color: #ffffff;
background-color: var(--vp-c-brand);
}
</style>
Type Declaration
ts
/**
* 下载在线链接资源文件
* @param url
* @param fileName
*/
declare function useDownloadFile(url: string, fileName: string): void;