由于某种原因,尝试下载文件时失败。我尝试了几种不同的方法,但都失败了。比我读到一些关于 pdf/word 文件在 Gatsby 中被“禁止”的内容??!
默认<a href="route-to-file" download></a>
好像没有用,显示下载失败。任何帮助表示赞赏!
最佳答案
见 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>Download the directly imported file</a>{` `}
<a href={`download.pdf`} download>Download the file that is already in your static folder</a>
</>
)
export default IndexPage
关于reactjs - 可下载文件 - Gatsby ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57258465/