React When a white stepped pit tour # 1 when the rear end pass over HTML code

Upon receiving the back end coming period img tag

 

 

Naive to think so on the line.

 

 <div className={styles.content_img} >
    {this.props.myCode}
 </div>

The results did not expect when I received this img he has become a string of emm

So the page is become so. . . . .

 

Then I found this document on react

dangerouslySetInnerHTML

https://zh-hans.reactjs.org/docs/dom-elements.html

 <div className={styles.content_img} dangerouslySetInnerHTML={{ __html: this.props.myCode}}>
 </div>

Perfect solution, ha ha ha.

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/wucc2333/p/11585685.html