[英]Add React app to static HTML page from another folder
I created a react app with multiple components as part of something bigger and I want to display that react app in a HTML page.我创建了一个包含多个组件的反应应用程序作为更大的一部分,我想在 HTML 页面中显示该反应应用程序。 I saw other posts but they had everything in a script file with the component in the script tag itself.我看到了其他帖子,但他们将所有内容都包含在脚本文件中,并且脚本标签本身中的组件。 I have a fully functioning chat app in another folder and I wanted to render that in the HTML file.我在另一个文件夹中有一个功能齐全的聊天应用程序,我想在 HTML 文件中呈现它。
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="html_container">
</div>
<script src="./reactApp/src/App.js">
<!-- add some magic here to have the app from the folder show up here -->
ReactDOM.render(
<App />,
document.getElementById('html_container')
);
</script>
</body>
</html>
You could use an iframe to render the react app inside the page, with the src
linking to your react app.您可以使用 iframe 在页面内呈现反应应用程序,并将src
链接到您的反应应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.