知识点小记🌟🌟🌟:dangerouslySetInnerHTML

2019-04-24  本文已影响0人  达摩会武术

具体用法咱也就是大概明白怎么使用,让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);
上一篇下一篇

猜你喜欢

热点阅读