美文网首页
知识点小记🌟🌟🌟:dangerouslySetInnerHTML

知识点小记🌟🌟🌟:dangerouslySetInnerHTML

作者: 达摩会武术 | 来源:发表于2019-04-24 10:20 被阅读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);
    

    相关文章

      网友评论

          本文标题:知识点小记🌟🌟🌟:dangerouslySetInnerHTML

          本文链接:https://www.haomeiwen.com/subject/mtewgqtx.html