在字符串中传递的HTML标记无法正常显示 [英] HTML tags passed within string not rendering fine

查看:276
本文介绍了在字符串中传递的HTML标记无法正常显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我是js新手,
  • 我有一个下拉滑块可以正常工作.
  • 使用p标签可以很好地显示内容
  • 但在该p标签中,我需要添加另一个链接或列表标签
  • 如果我给它显示整个标签,但它不会像普通网页一样呈现.因为我在给琴弦content = {PLAYER.accordion(ballInfo,"qwe

    testing

  • 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

     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>")} />

推荐答案

我不是反应专家,但是您可以尝试一下替换吗

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

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

有了这个

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

这篇关于在字符串中传递的HTML标记无法正常显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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