点击实现下载/打开文件

//定义一个a标签节点
var nowA = document.createElement('a');
//在新的空白页面打开 nowA.target = '_blank';
//设置a标签的href(此处填文件的路径) nowA.setAttribute('href', url);
//设置下载文件的文件名,不填默认为路径 nowA.setAttribute('download', '');
//将a标签隐藏 nowA.style.display = 'none';
//往页面上添加此节点 document.body.appendChild(nowA);
//点击a标签进行下载 nowA.click();
//移除创建的节点 document.body.removeChild(nowA);