简体   繁体   English

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

[英]Is there a way to link non-react html files in a react app?

Let's say I have a react application hosted at example.com. 假设我在example.com上托管了一个React应用程序。 Now, I already have a very simple html/js website that I want to display at example.com/example. 现在,我已经有一个非常简单的html / js网站,我想在example.com/example上显示它。 I can easily do this if I rewrite the website in react, but I don't want to do that because the html/js website is so simple and it would be unnecessary to be written in react. 如果我用react重写网站,我可以很容易地做到这一点,但是我不想这样做,因为html / js网站是如此简单,因此无需编写react。

Is there any way I can directly put and link this html/js website with the rest of my project? 有什么办法可以直接将这个html / js网站与我的项目的其余部分链接起来?

When you create React app with create-react-app you have the following filesystem structure: 使用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 https://facebook.github.io/create-react-app/docs/folder-structure

So, you can just create any static pages in /public directory and reference them. 因此,您可以在/public目录中创建任何静态页面并对其进行引用。 All the resources in /public directory will be available in the root of your website. /public目录中的所有资源将在您网站的根目录中可用。

For example, custom-page.html will be accessible by http://localhost:3000/custom-page.html . 例如, custom-page.html会被访问的http://本地主机:3000 /定制page.html中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM