React - How to open PDF file as a href target blank

前端 未结 6 658
感情败类
感情败类 2021-01-04 00:19

This mundane task fairly simple on static views, isn\'t complying with React.

Can someone advise me how to open a pdf file as a href on a new tab?

Here\'s my

6条回答
  •  青春惊慌失措
    2021-01-04 01:08

    I have solved that by creating _someFolder in the public folder and then in the component:

    import {pdfFile} from "/_someFolder/pdfFile.pdf";
    
    ....
    
    
    window.open(pdfFile)}> Help
    ....

    that prevent by adding hashes to the filename when serviceWorker is used.

提交回复
热议问题