HTML tags passed within string not rendering fine

混江龙づ霸主 提交于 2019-12-24 08:51:31

问题


  • I am new to js,
  • I have a drop down slider working fine.
  • Content shows fine with p tag
  • but within that p tag i need to add another link or list tag
  • If I give it displays the whole a tag but it doesnot render like a normal web page. since I am giving a string. content={PLAYER.accordion(ballInfo, "qwe

    testing

    "
    )}
  • can you tell me how to fix it.
  • providing my code below
     static accordion(ballInfo, content) {
        if (ballInfo.isRetrieving) {
            return (





 <AccordionHeader className="jump-player-question-title jump-submenu-dropmenuHeader" header="ball ball ball ball sjsdsdkjjksddjks?" content={PLAYER.accordion(ballInfo, "qwe <p> testing</p>")} />

 <AccordionHeader className="jump-player-question-title jump-submenu-dropmenuHeader" header="dsknjdsncjdnsjkcsdnjcsdncjkdsn" content={PLAYER.accordion(ballInfo, "asd <a href="#">testing 2</a>")} />

回答1:


I am not a react expert, but can you try with this, replace

<p> {{content}} </p>

With this

<p dangerouslySetInnerHTML={{__html: content}} />


来源:https://stackoverflow.com/questions/43622318/html-tags-passed-within-string-not-rendering-fine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!