假设拉取下来的是富文本携带html标签的内容应该如何渲染到页面:
例:<div>我是富文本内容</div>
在标签上使用dangerouslySetInnerHTML={{__html:this.state.article}}
import React, { Component } from 'react';
class TodoList extends Component {
constructor(){
super()
this.state={
article:"<div>我是富文本内容</div>",
}
}
render() {
return (
<div className="App">
<div dangerouslySetInnerHTML={{__html:this.state.article}}></div>
</div>
);
}
}
export default TodoList
标签:TodoList,标签,Component,react,state,html,文本 From: https://blog.51cto.com/u_12422954/5985783