如何在 docusaurus 中链接可下载文件?
我想在我的文档上链接可下载内容,我尝试放入这样的链接:
<a
href={
require("@site/static/img/04-api/01/API-Description.png")
.default
} download="file-name"
> download </a>
这会生成以下 html:
<a download="file-name" href="/assets/images/API-Description-6aeb65d8ae136a70b1b5a3d916d27ca0.png"> download </a>
<a download="file-name" href="/assets/images/API-Description-6aeb65d8ae136a70b1b5a3d916d27ca0.png"> download </a>
当我单击该链接时,我得到
“找不到页面”
我正在运行的版本:2.0.0-beta.17
I want to link downloadable content on my documentation and I tried putting in a link like this:
<a
href={
require("@site/static/img/04-api/01/API-Description.png")
.default
} download="file-name"
> download </a>
This generates following html:
<a download="file-name" href="/assets/images/API-Description-6aeb65d8ae136a70b1b5a3d916d27ca0.png"> download </a>
<a download="file-name" href="/assets/images/API-Description-6aeb65d8ae136a70b1b5a3d916d27ca0.png"> download </a>
When I click on the link, I get
"Page Not Found"
I am running version: 2.0.0-beta.17
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了两种方法来做到这一点。
首先,将文件放入
static
文件夹中。示例:
./static/image.png
。1) 你的方式
2) 简单的方式
** 请注意,我们没有使用
!
来表明这是一个图像。I have found two ways of doing this.
First, put the file inside the
static
folder.Example:
./static/image.png
.1) Your way
2) Simple way
** Note that we did not use the
!
to indicate that is an image.您必须将 inline-html 与
download
属性和target="_blank"
一起使用You had to use inline-html with the
download
attribute andtarget="_blank"