有没有办法在React应用中链接未反应的html文件?

时间:2019-03-25 20:47:41

标签: javascript html reactjs

假设我在example.com上托管了一个React应用程序。现在,我已经有一个非常简单的html / js网站,我想在example.com/example上显示它。如果我用react重写网站,我可以很容易地做到这一点,但是我不想这样做,因为html / js网站是如此简单,因此无需编写react。

有什么办法可以直接将这个html / js网站与我的项目的其余部分链接起来?

1 个答案:

答案 0 :(得分:1)

使用create-react-app创建React应用时,您将具有以下文件系统结构:

my-app/
 README.md
 node_modules/
 package.json
 public/
   index.html
   custom-page.html <-- Create custom page
   favicon.ico
 src/
   App.css
   App.js
   App.test.js
   index.css
   index.js
   logo.svg

https://facebook.github.io/create-react-app/docs/folder-structure

因此,您可以只在/public目录中创建任何静态页面并对其进行引用。 /public目录中的所有资源将在您网站的根目录中可用。

例如,http://localhost:3000/custom-page.html将访问custom-page.html