如何在反应组件中使用聚合物组件?是否可以? [英] How can one use a polymer component inside a react component ? Is it possible?

查看:50
本文介绍了如何在反应组件中使用聚合物组件?是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 google 的聚合物制作了 web 组件,但我也对尝试使用 react 非常感兴趣.所以我想知道是否可以从反应组件的渲染函数内部使用聚合物组件?

I have used google's polymer to make web components but i am also very interested in giving react a try. So i want to know whether it is possible to use the polymer component from inside the render function of a react component ?

推荐答案

是的,这是可能的!我使用的方法有点复杂,但我很乐意分享.

Yes it is possible ! I did it using a method thats kinda bit complicated but i would love to share it.

如果您已经使用过聚合物,那么只需像使用任何其他聚合物元素一样直接使用聚合物即可.您所要做的就是将此 react 文件夹转换为 js.您可以按照本教程将 jsx 转换为 js.并且使用任何聚合物元素都没有问题.

if you have already used polymer then just directly use the polymer the way you use it any other polymer element. all you have to do is convert this react folder to a js. You can follow this tutorial in order to convert a jsx to js. and use any polymer element without a problem.

https://www.youtube.com/watch?v=4WUATF3hGUQ

这不是我的教程,而是我在 youtube 上看到的.本教程的所有学分都归于codingwithjesse

This is not my tutorial but something i saw on youtube . all credits for this tutorial go to codingwithjesse

根据 WiredPraire 的要求,我想向您展示一个示例

As asked by WiredPraire , i would like to show you with an example

这是我的 index.html :

this is my index.html :

这是 poly-react.html 的聚合物元素:

This is poly-react.html the polymer element:

这是我的 polyreact.jsx,里面也有聚合物元素

This is my polyreact.jsx which also has polymer element inside

并且 jsx 上面的聚合物开始处理这个转换,这可以使用教程来完成:

and the polymer inside above jsx started working with this transformation which can be done using the tutorial:

索引文件也必须像这样更改:

The index file also has to be changed like this:

希望这有帮助!!!!!!!!!

hope this helps!!!!!!!!

这篇关于如何在反应组件中使用聚合物组件?是否可以?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆