react escape string into html statement

When using the reactjs library, you will encounter a string of html, and then insert it into the page to display it in the form of html. However, if you insert it directly, the page will display this string without escaping. You can insert it in the following way and display it in the form of html:

<div dangerouslySetInnerHTML={{__html: "<p>爱死费崇政</p>"}} />

 

Article from: https://blog.csdn.net/fay462298322/article/details/71514030

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325245629&siteId=291194637