reactjs - 为 React-PDF 提供正确的路径
问题描述
我正在尝试使用 React-PDF 在我的组件中显示一个 pdf,但无法弄清楚如何为它提供我的 pdf 的正确路径。我的文件位于 ReactApp/public/pdf/myPdf.pdf
这就是我要走的路:
<Document
file={filepath}
>
</Document>
到目前为止,我尝试了以下没有运气:
pdf/GenericCustomerConsentAgreement.pdf
/pdf/GenericCustomerConsentAgreement.pdf
./pdf/GenericCustomerConsentAgreement.pdf
../pdf/GenericCustomerConsentAgreement.pdf
%PUBLIC_URL%/pdf/GenericCustomerConsentAgreement.pdf
但是,我可以使用以下方法加载文件:
本地主机:61631/pdf/GenericCustomerConsentAgreement.pdf
解决方案
推荐阅读
- python - 如何在 Python 的 Apache-Beam DataFlow 中组合解析的文本文件?
- python - regexp_replace 的元组索引超出范围 - pyspark-sql
- python - 从多个图像中检测目标:从多个图像中提取检测到的边界框
- python - 在云服务器上托管 RASA NLU 模型
- environment-variables - 保存 Postman 环境变量无法正常工作?
- c# - Oracle.DataAccess.Client.OracleException:数据提供者内部错误(-3000)[System.String]
- python - 小写特定案例的列表,而不是其他案例
- javascript - 如何在javascript中以表单形式进行验证?
- azure - Azure AD JWT 令牌验证选项
- google-cloud-platform - 使用 Stackdriver 的 GoogleCloud 生产访问控制