美文网首页
js前端base64转word并下载

js前端base64转word并下载

作者: 爱代码的派派星 | 来源:发表于2020-08-24 21:16 被阅读0次
    代码如下
    
    var raw = window.atob(ba);
    var uInt8Array = new Uint8Array(raw.length);
    for (var i = 0; i < raw.length; i++) {
      uInt8Array[i] = raw.charCodeAt(i);
    }
    
    const link = document.createElement("a");
    const blob = new Blob([uInt8Array],{
      // type: 'application/vnd.ms-excel'
      type: 'application/msword'
    })
    
    link.style.display = 'none';
    link.href = URL.createObjectURL(blob);
    //link.setAttribute('download','对比结果_'+$scope.你的变量+'.xls');
    link.setAttribute('download','对比结果');
    
    document.body.appendChild(link)
    link.click()
    
    document.body.removeChild(link)
    

    相关文章

      网友评论

          本文标题:js前端base64转word并下载

          本文链接:https://www.haomeiwen.com/subject/mstxjktx.html