0.0.5 • Published 3 years ago

@jzyong/downloadfile v0.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

ajax文件下载工具

测试版,有待项目实践验证

使用方法

/**
@param {String} url 请求地址
@param {String} filename 下面的文件名称
@param {String} filetype 转换的文件类型(一般需要与后端传来的文件类型一直),xlsx设置为application/vnd.ms-excel;
@param {String} config.method 请求方式: get,post等
@param {Object} config.header 请求添加的header头
@param {Object} config.body 请求附带的data数据
@param {Function} config.onError 出错时的钩子函数
@param {Function} config.onSuccess 成功下载时的钩子函数
*/
exportFile(url,filename,filetype, config = {method, header, data, onError, onSuccess})

用例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用例</title>
    <script src="/downloadFile.js"></script>
</head>
<body>
<button
        onclick="downloadFile('/test.xlsx','test.xls','application/vnd.ms-excel;')">下载
</button>
</body>
</html>
0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago