由于某种原因,当尝试下载文件时,它失败。我尝试了几种不同的方法,但都失败了。比我读到的有关Gatsby中pdf / word文件被“禁止”的内容??!
默认的<a href="route-to-file" download></a>
似乎不起作用,它显示下载失败。任何帮助表示赞赏!
答案 0 :(得分:2)
请参见Importing Assets Directly Into Files和Using the Static Folder
import React from "react"
import downloadFile from '../downloads/file.pdf'
const IndexPage = () => (
<>
<a href={downloadFile} download>imported file</a>{` `}
<a href={`download.pdf`} download>file from static folder </a>
</>
)
export default IndexPage