简体   繁体   English

React中的HTML解析器无法正确解析脚本

[英]Html parser in React not parsing correctly script

I am using this library https://www.npmjs.com/package/html-to-react for html parsing but for some reason the scripts are not parsed correctly or probably I am missing some configurations. 我正在使用该库https://www.npmjs.com/package/html-to-react进行html解析,但由于某些原因,脚本无法正确解析,或者可能缺少某些配置。

The html,js (embedded code from infogram) looks like this: html.js(信息报中的嵌入式代码)如下所示:

<div class="infogram-embed" data-id="bc973e33-5e3e-4bf3-b587-9a6f16caf158" data-type="interactive" data-title="Konsumtionslån från Norden ökar"></div><script>!function(e,t,s,i){var n="InfogramEmbeds",o=e.getElementsByTagName("script")[0],d=/^http:/.test(e.location)?"http:":"https:";if(/^/{2}/.test(i)&&(i=d+i),window[n]&&window[n].initialized)window[n].process&&window[n].process();else if(!e.getElementById(s)){var r=e.createElement("script");r.async=1,r.id=s,r.src=i,o.parentNode.insertBefore(r,o)}}(document,0,"infogram-async","https://e.infogram.com/js/dist/embed-loader-min.js");</script><div style="padding:8px 0;font-family:Arial!important;font-size:13px!important;line-height:15px!important;text-align:center;border-top:1px solid #dadada;margin:0 30px"><a href="https://infogram.com/bc973e33-5e3e-4bf3-b587-9a6f16caf158" style="color:#989898!important;text-decoration:none!important;" target="_blank">Konsumtionslån från Norden ökar</a><br><a href="https://infogram.com" style="color:#989898!important;text-decoration:none!important;" target="_blank" rel="nofollow">Infogram</a></div>

And I parse it as htmlToReactParser.parse(html)} but for some reason is not working. 我将其解析为htmlToReactParser.parse(html)}但由于某些原因无法正常工作。

I will also attach a print screen how the dom looks like in inspector. 我还将附加一个打印屏幕,以了解dom在检查器中的外观。 在此处输入图片说明

So basically my problem is that I dont see infogram graphs appearing on my react app. 所以基本上我的问题是我看不到我的react应用程序上出现的信息图图表。

问题出在https:“附近的脚本;如果((/ ^ / {2} /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM