简体   繁体   English

构建后编辑 React 生成的内容

[英]Editing the generated content of React after build

I'm using react-snap to pre-generate my website content instead of client side rendering.我正在使用react-snap来预生成我的网站内容,而不是客户端渲染。

After building the project, when I manually edit index.html , the changes only get applied if the edited elements are outside <div id="root"/> .构建项目后,当我手动编辑index.html时,仅当编辑的元素在<div id="root"/>之外时才会应用更改。

I can add scripts and meta tags to the <head/> or to the bottom of <body/> ;我可以将scriptsmeta标记添加到<head/><body/>的底部; but nothing happens when I edit the content of <div id="root"/> .但是当我编辑<div id="root"/>的内容时没有任何反应。 When I inspect the site the contents have not changed but the code inside html file is different.当我检查站点时,内容没有改变,但html文件中的代码不同。

What is causing this behavior and how can I bypass it?是什么导致了这种行为,我该如何绕过它?

Why do you need to edit index.html ?为什么需要编辑index.html By default, create-react-app uses index.html as a fallback.默认情况下, create-react-app使用index.html作为后备。

Make sure you're not using self-closing tags like this: <div id="root"/>确保你没有使用这样的自闭标签: <div id="root"/>

and replace with this:并替换为:

<div id="root"> </div>

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

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