happy-utils
Version:
共用函数库,提取出大部分业务需要的共用的函数。
20 lines (18 loc) • 383 B
JavaScript
/**
* @desc 生成下载
* @param {href,title}
*/
function download(href, title) {
//火狐专用
if (navigator.userAgent.indexOf("Firefox") > 0) {
window.location = href
return
}
const a = document.createElement('a');
a.setAttribute('href', href);
a.setAttribute('download', title);
a.click();
}
module.exports = {
download
}