Reactjs convert html string to jsx

前端 未结 9 1463
夕颜
夕颜 2020-11-22 10:09

I\'m having trouble dealing with facebook\'s ReactJS. Whenever I do ajax and want to display an html data, ReactJS displays it as text. (See figure below)

9条回答
  •  我在风中等你
    2020-11-22 10:31

    i found this js fiddle. this works like this

    function unescapeHTML(html) {
        var escapeEl = document.createElement('textarea');
        escapeEl.innerHTML = html;
        return escapeEl.textContent;
    }
    
    
    

    jsfiddle link

提交回复
热议问题