简体   繁体   中英

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.

The html,js (embedded code from infogram) looks like this:

<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.

I will also attach a print screen how the dom looks like in inspector. 在此处输入图片说明

So basically my problem is that I dont see infogram graphs appearing on my react app.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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