从普通JSX外部脚本从运行时加载一个React组件
一般而言,我必须在运行时加载和渲染的选项是什么,我在未编译的JSX Plain脚本中拥有的React组件是:也许是从字符串或URL中。显然,组件脚本可以从同一应用的其他(静态)组件或其他外部软件包中导入。
注意:这是针对公司的内部网络应用程序,也就是说,没有强大的安全要求。
In general terms, what are the options that I have to load and render in runtime a React component that I have in an uncompiled JSX plain script somewhere: maybe from a string or from a url. Obviously the component script can have imports from other (static) components of the same app or from other external packages.
Note: it's for an internal web app of a company, that is, there are no strong security requirements.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这样的唯一简单选择是使用babel独立,它可以在客户端对JS转换进行JSX。将JSX字符串插入
< script type =“ text/babel”>
,并包括react,react dom和babel独立作为页面上的脚本。The only easy-ish option I'm aware of for something like that is to use Babel Standalone, which does JSX to JS transformation on the client-side. Insert the JSX string into a
<script type="text/babel">
, and include React, React DOM, and Babel Standalone as scripts on the page.