html:
<button class="download" onclick=" download('url')">
<i class="layui-icon layui-icon-download-circle"></i>
</button>
url为要下载源文件的地址。
Javascript
function download(src) {
var $a = document.createElement('a');
$a.setAttribute("href", src);
$a.setAttribute("download", "");
var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
$a.dispatchEvent(evObj);
}