[英]Modular 3rd party widget in react and webpack 2
I am trying to develop a 3rd party widget that other websites would be able to use. 我正在尝试开发其他网站可以使用的第三方小部件。 I have already built a web app with react/webpack2 but it works as an actual website. 我已经用react / webpack2构建了一个Web应用程序,但是它可以作为一个实际的网站使用。
I am struggling to achieve it working as a widget. 我正在努力实现它作为小部件的工作。 My goal would be to have different modules loaded in different pages by setting a param in the main widget element like so: 我的目标是通过在主窗口小部件元素中设置参数来将不同的模块加载到不同的页面中,如下所示:
<my-widget module="module1" additional-param="param">
第1页: <my-widget module="module1" additional-param="param">
<my-widget module="module2" additional-param="param">
第2页: <my-widget module="module2" additional-param="param">
Any examples or best practices would be appreciated. 任何示例或最佳做法将不胜感激。
IMO, you can achieve this through IMO,您可以通过实现
<My-widget children={ ({ param }) => (<Module1 { ...param } /> } />
using children as props will work just like <My-Widget><Module1 /><My-Widget>
将孩子用作道具就像<My-Widget><Module1 /><My-Widget>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.