我正试图将我的简历.pdf文件添加到我的投资组合网站,目标是该文件一旦被点击就可以下载.我将.pdf文件和一个tyes.s.ts文件夹添加到了src文件夹中.
我将pdf文件导入到Resume.tsx组件中:
import resumePDF from "../src/Resume.pdf";
个
下载按钮:
<a href={resumePDF}>
<button id="resume-button">Download Resume</button>
</a>
我在上面的代码中遇到以下错误:
ERROR in src/Resume.tsx:2:23
TS2307: Cannot find module '../src/Resume.pdf' or its corresponding type declarations.
1 | import React from "react";
> 2 | import resumePDF from "../src/Resume.pdf";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 |
4 | function Resume() {
5 | return (
当我转到tyes.s.ts文件时,我看到以下错误:
ERROR in src/types.s.ts:1:16
TS2664: Invalid module name in augmentation, module '*.pdf' cannot be found.
> 1 | declare module "*.pdf";
| ^^^^^^^
2 |
3 | export default module;
4 |
根据我所阅读的内容,我应该将EXPORT添加到tyes.s.ts文件的底部,但我不确定在这里还应该添加什么.