[英]I need my ReactJS app working offline without server
I have simple one page html/js/ReactJS app which is used with the help of such scripts added to index.html.我有一个简单的一页 html/js/ReactJS 应用程序,它在添加到 index.html 的此类脚本的帮助下使用。 It is running without any server, because client needs it to be used only on his computer:
它在没有任何服务器的情况下运行,因为客户端只需要在他的计算机上使用它:
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js"></script>
How can I make this app working offline?我怎样才能让这个应用离线工作? I can use Node Server, but when application is downloaded by client it needs to be opened using the only
index.html
file.我可以使用节点服务器,但是当客户端下载应用程序时,它需要使用唯一的
index.html
文件打开。
Just download the three files above:只需下载上面的三个文件:
react
: https://unpkg.com/react@16/umd/react.production.min.js react
: https : //unpkg.com/react@16/umd/react.production.min.jsreact-dom
: https://unpkg.com/react-dom@16/umd/react-dom.production.min.js react-dom
: https : //unpkg.com/react-dom@16/umd/react-dom.production.min.jsbabel
: https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js babel
: https : //cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js You can do this by going to the src links in your script tags above, right-click the webpage, click Save As
, choose file type as JavaScript and then replace the above src links in your index.html to those downloaded files.您可以通过转到上面脚本标签中的 src 链接,右键单击网页,单击
Save As
,选择文件类型为 JavaScript,然后将 index.html 中的上述 src 链接替换为那些下载的文件。
You can create a special folder for the site and within the folder, you can paste a copy of your index.html file as well as a js folder and keep the above three downloaded JavaScript files in that js folder.您可以为站点创建一个特殊文件夹,在该文件夹中,您可以粘贴 index.html 文件的副本以及一个 js 文件夹,并将上述三个下载的 JavaScript 文件保存在该 js 文件夹中。
You can now simply replace the src link in the above three scripts tags like this:您现在可以简单地替换上述三个脚本标签中的 src 链接,如下所示:
<script src="js/react.production.min.js" />
<script src="js/react-dom.production.min.js" />
<script src="js/babel.min.js" />
However, this only works if the client is just viewing the site.但是,这仅在客户端只是查看站点时才有效。 If the client wants to say, edit the files and want something like
hot reload
, they will need to set up a server for that.如果客户端想说,编辑文件并想要诸如
hot reload
类的东西,他们将需要为此设置一个服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.