• <tfoot id='bg8x9'></tfoot>
    • <bdo id='bg8x9'></bdo><ul id='bg8x9'></ul>

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

      <legend id='bg8x9'><style id='bg8x9'><dir id='bg8x9'><q id='bg8x9'></q></dir></style></legend>

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

        带有 React 的可嵌入 JavaScript 小部件

        时间:2023-09-07

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

            <tfoot id='k4WC9'></tfoot>

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

                • <bdo id='k4WC9'></bdo><ul id='k4WC9'></ul>
                    <tbody id='k4WC9'></tbody>
                  <legend id='k4WC9'><style id='k4WC9'><dir id='k4WC9'><q id='k4WC9'></q></dir></style></legend>
                  本文介绍了带有 React 的可嵌入 JavaScript 小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以使用 React JavaScript 库创建可嵌入的 JavaScript 小部件,其中:

                  Is it possible to create an embeddable JavaScript widget using the React JavaScript library, where:

                  1. React 库嵌入"在小部件中
                  2. 嵌入的 React 库的版本可以与加载小部件的页面上的 React 库不同,就像可以使用 jQuery 一样.

                  我正在寻找如下所述的功能:

                  I'm lookin for functionality as described in:

                  • http://blog.swirrl.com/articles/creating-asynchronous-embeddable-javascript-widgets/
                  • http://shootitlive.com/2012/07/developing-an-embeddable-javascript-widget/

                  推荐答案

                  对于你提到的需求,最好的解决方案是browserify(或类似的).使用 reactify 转换,您可以让 JSX 到 JS 一步完成.Browserify(和 Webpack)在 React 社区中非常常见,因此几乎所有库都发布到 npm 以方便使用.

                  For the requirements you mentioned, the best solution is browserify (or similar). Using reactify transform you can have the JSX to JS happen all in one step. Browserify (and Webpack) are very common the react community, so nearly all libraries are published to npm for easy consumption.

                  Browserify 将您的 JavaScript、您选择的 React 版本和任何库打包到一个 JS 文件中,该文件不使用全局变量或与页面上运行的其他代码冲突的其他模式.

                  Browserify packs your JavaScript, your React version of choice, and any libraries into a single JS file which doesn't use globals or other patterns that conflict with other code running on the page.

                  您还可以查看诸如 react-css 之类的一些库,以将您的样式与页面样式隔离开来.样式也将在您的包中隔离.当然,如果页面执行 div {margin: 1em} 之类的操作,则唯一的解决方案是 iframe 或 web-components.

                  You can also look into some libs like react-css to isolate your styles from the page styles. The styles will also be isolated in your bundle. Of course if the page does something like div {margin: 1em}, the only solutions are iframes or web-components.

                  这篇关于带有 React 的可嵌入 JavaScript 小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何保护小部件免受伪造请求 下一篇:iframe 是一个糟糕的主意吗?

                  相关文章

                  <tfoot id='Nxmrs'></tfoot>
                • <small id='Nxmrs'></small><noframes id='Nxmrs'>

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

                        <bdo id='Nxmrs'></bdo><ul id='Nxmrs'></ul>
                      <legend id='Nxmrs'><style id='Nxmrs'><dir id='Nxmrs'><q id='Nxmrs'></q></dir></style></legend>