zoukankan      html  css  js  c++  java
  • 前端下载文件(GET、POST方法)

    GET

    location.href = '/path/to/download/url'

    POST

    axios.post('/path/to/download/url', this.searchParams, {
    responseType: 'blob'
    }).then(res => {
    let blob = res.data
    let reader = new FileReader()
    reader.readAsDataURL(blob)
    reader.onload = (e) => {
    let a = document.createElement('a')
    a.download = `表格名称.xlsx`
    a.href = e.target.result
    document.body.appendChild(a)
    a.click()
    document.body.removeChild(a)
    }
    }).catch(err => {
    console.log(err.message)
    })

    时而疯狂女汉子,时而温柔软妹子
  • 相关阅读:
    软考
    码云
    vue和bpmnjs
    工作流引擎
    net core restapi
    工厂模式
    sqlmanage
    类的扩展
    导出excel
    拼图
  • 原文地址:https://www.cnblogs.com/csji/p/12929682.html
Copyright © 2011-2022 走看看