具体用法咱也就是大概明白怎么使用,让html字符串不被转译,就用这个dangerouslySetInnerHTML。
import React ,{Component}from "react";
import {DetailWrapper, Header,Content} from "./style";
import {connect} from "react-redux";
class Detail extends Component{
render(){
return (
<DetailWrapper>
<Header>{this.props.title}</Header>
<Content dangerouslySetInnerHTML={{__html:this.props.content}}>
</Content>
</DetailWrapper>
)
}
}
const mapStateToPorps=(state)=>({
title:state.getIn(["detail","title"]),
content:state.getIn(["detail","content"])
})
export default connect(mapStateToPorps,null)(Detail);
网友评论