可下载文件-Gatsby [英] Downloadable File - Gatsby

查看:52
本文介绍了可下载文件-Gatsby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,当尝试下载文件时,它失败.我尝试了几种不同的方法,但都失败了.比我读到的有关Gatsby中pdf/word文件被禁止"的内容??!

For some reason when trying to download a file, it fails. I've tried few different ways, all of them failed. Than I read something about pdf/word files are "forbidden" in Gatsby ??!

默认的<a href="route-to-file" download></a>似乎不起作用,它显示下载失败.感谢您的帮助!

The default <a href="route-to-file" download></a> doesn't seem to work, it shows failed to download. Any help is appreciated!

推荐答案

请参见直接将资产导入文件使用静态文件夹

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 from the static folder</a>
  </>
)

export default IndexPage

这篇关于可下载文件-Gatsby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆