• <tfoot id='berII'></tfoot>

  • <small id='berII'></small><noframes id='berII'>

      <legend id='berII'><style id='berII'><dir id='berII'><q id='berII'></q></dir></style></legend>
        <i id='berII'><tr id='berII'><dt id='berII'><q id='berII'><span id='berII'><b id='berII'><form id='berII'><ins id='berII'></ins><ul id='berII'></ul><sub id='berII'></sub></form><legend id='berII'></legend><bdo id='berII'><pre id='berII'><center id='berII'></center></pre></bdo></b><th id='berII'></th></span></q></dt></tr></i><div id='berII'><tfoot id='berII'></tfoot><dl id='berII'><fieldset id='berII'></fieldset></dl></div>
          <bdo id='berII'></bdo><ul id='berII'></ul>
      1. React:如何在页面中两次渲染组件?

        React: How to render a component twice in a page?(React:如何在页面中两次渲染组件?)

        1. <i id='deiXj'><tr id='deiXj'><dt id='deiXj'><q id='deiXj'><span id='deiXj'><b id='deiXj'><form id='deiXj'><ins id='deiXj'></ins><ul id='deiXj'></ul><sub id='deiXj'></sub></form><legend id='deiXj'></legend><bdo id='deiXj'><pre id='deiXj'><center id='deiXj'></center></pre></bdo></b><th id='deiXj'></th></span></q></dt></tr></i><div id='deiXj'><tfoot id='deiXj'></tfoot><dl id='deiXj'><fieldset id='deiXj'></fieldset></dl></div>
            <bdo id='deiXj'></bdo><ul id='deiXj'></ul>
              <tbody id='deiXj'></tbody>

              <small id='deiXj'></small><noframes id='deiXj'>

            1. <legend id='deiXj'><style id='deiXj'><dir id='deiXj'><q id='deiXj'></q></dir></style></legend>
                  <tfoot id='deiXj'></tfoot>

                  本文介绍了React:如何在页面中两次渲染组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 React 中有一个组件构建myComponent.js

                  I have a component build in ReactmyComponent.js

                  ReactDOM.render(
                    <MyComponent />,
                    document.getElementById('my-id')
                  );
                  

                  在我的 Html 中,我想渲染两次,HTML 如下:

                  In my Html, I want to render it twice, the HTML is as following:

                  <div id='my-id></div>
                  some html
                  <div id='my-id></div>
                  

                  我想在这个页面中反应渲染两次,但它只为第二个 div 渲染一次.反正有没有渲染两次?

                  I want react render twice in this page, but it only render once for the second div. Is there anyway to render it twice?

                  推荐答案

                  HTML 中的两个或多个元素不能有相同的 id.使用不同的ids

                  You can't have the same id for two or more elements in HTML. Use different ids

                  <div id='my-id-one></div>
                  some html
                  <div id='my-id-two></div>
                  

                  并为每个 id 分别调用 ReactDOM.render.

                  and call the ReactDOM.render separately for each id.

                  ReactDOM.render(
                    <MyComponent />,
                    document.getElementById('my-id-one')
                  );
                  
                  ReactDOM.render(
                    <MyComponent />,
                    document.getElementById('my-id-two')
                  );
                  

                  这篇关于React:如何在页面中两次渲染组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                • <tfoot id='8qKfJ'></tfoot>

                  <small id='8qKfJ'></small><noframes id='8qKfJ'>

                  • <bdo id='8qKfJ'></bdo><ul id='8qKfJ'></ul>
                          <legend id='8qKfJ'><style id='8qKfJ'><dir id='8qKfJ'><q id='8qKfJ'></q></dir></style></legend>
                        • <i id='8qKfJ'><tr id='8qKfJ'><dt id='8qKfJ'><q id='8qKfJ'><span id='8qKfJ'><b id='8qKfJ'><form id='8qKfJ'><ins id='8qKfJ'></ins><ul id='8qKfJ'></ul><sub id='8qKfJ'></sub></form><legend id='8qKfJ'></legend><bdo id='8qKfJ'><pre id='8qKfJ'><center id='8qKfJ'></center></pre></bdo></b><th id='8qKfJ'></th></span></q></dt></tr></i><div id='8qKfJ'><tfoot id='8qKfJ'></tfoot><dl id='8qKfJ'><fieldset id='8qKfJ'></fieldset></dl></div>
                              <tbody id='8qKfJ'></tbody>