vue 下載阿里雲OSS遠程圖片,跨域問題, No 'Access-Control-Allow-Origin' header is present on the requested resource


  • 使用以下方法,也不用去阿里雲后台設置允許跨域了
downloadIamge(imgsrc, name) {
  const src = `${imgsrc}?t=${new Date().getTime()}`
  fetch(src).then(res => {
    res.blob().then(myBlob => {
      const href = URL.createObjectURL(myBlob)
      const a = document.createElement('a')
      a.href = href
      a.download = name
      a.click()
      a.remove()
    })
  })     
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM