• <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:如何在页面中两次渲染组件?

        时间:2023-09-07

        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:如何在页面中两次渲染组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何处理角度5递归未知确切数字路由器参数? 下一篇:创建具有 6 个角度而不是 4 个角度的自定义 HTML div

                  相关文章

                • <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>
                  1. <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>