Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在reactjs中显示字符串中的html_Javascript_Html_Json_Reactjs - Fatal编程技术网

Javascript 在reactjs中显示字符串中的html

Javascript 在reactjs中显示字符串中的html,javascript,html,json,reactjs,Javascript,Html,Json,Reactjs,如何使用js在html页面中显示json字符串中的html 迄今为止的代码: function RequestNoteItem(props) { return( <li className={ props.isAdmin == 1 ? "out" : "in"} > <div className="message" style={props.isAdmin==1 ? {marginRight: 0} : {marginLef

如何使用js在html页面中显示json字符串中的html

迄今为止的代码:

function RequestNoteItem(props) {
    return(
        <li className={ props.isAdmin == 1 ? "out" : "in"} >
            <div className="message" style={props.isAdmin==1 ?   {marginRight: 0} : {marginLeft: 0} }>
                <span className="arrow"> </span>
                <a  href="#" className="name"> {props.username} </a>
                <a onClick={props.onDelete} id={props.id}  style={{color:'red'}} className={ props.isAdmin == 1 ? "pull-left" : "pull-right"}>✖</a>

                <span className="datetime"> {props.time}</span>
                <span className="body"  style={{maxWidth:900+'px'}}> {props.content } </span>
            </div>
        </li>
    )
}
函数请求注释项(道具){
返回(
  • 连同一些附件和下列文件包一起发送给Karim:-“,
  • 使用
    DangerlySetinerHTML
    属性来呈现
    html
    字符串

    发件人:

    危险的LysetinerHTML是React在中使用innerHTML的替代品 浏览器是DOM

    检查此示例:

    var string=”“;
    类应用程序扩展了React.Component{
    render(){
    返回(
    )
    }
    }
    ReactDOM.render(,document.getElementById('app'))
    
    
    您能提供一些您拥有的代码吗。@如果我正在使用react js,这是包含上面照片中视图的组件JSON字符串是什么,您希望输出的外观如何like@ShubhamKhatri我更新了我的问题,这是我从json获取的字符串我想显示html链接您获取的字符串不是json s串
    note: "<a href=/system/web/email//request-packagedefault/index?id=42 >Email</a> sent to Karim with some attachments and follwing packages: - <a href=/system/web/request/request-package?id=1 >wefwef</a>- <a href=/system/web/request/request-package?id=2 >w ferg</a>- <a href=/system/web/request/request-package?id=3 >rthrth</a>- <a href=/system/web/request/request-package?id=4 >ewrgwergerg</a>",