美文网首页
React转义字符

React转义字符

作者: SherrinfordL | 来源:发表于2019-08-29 17:23 被阅读0次

    首先贴上自己一小段code

    {/* 图表 */}
                                <div className="chartWaveDay"></div>
                                <span style={{margin:'20px 0px 0px 20px',fontSize:12,position:'relative'}}>DAU(日活跃用户量)</span>                            
                                <span className="todayDataNum">{this.state.todayDataNum[0]}</span>
                                <div className="todayDataD">                                
                                    <div className='todayDataInB'>
                                        <span style={{color:'black'}}>日</span>
                                        <span className="todayDataIcon" style={{color:(this.state.todayDataIcon1[0]==1?"red":"green")}} dangerouslySetInnerHTML = {{ __html:this.state.todayDataIcon1[0]==1?'&#8593;':'&#8595;' }}></span>
                                        <span className="dataVal">{this.state.dataVal1[0]}</span>                                    
                                    </div>                                                                
                                    <div className='todayDataInB'>
                                        <span style={{color:'black'}}>周</span>
                                        <span className="todayDataIcon" style={{color:(this.state.todayDataIcon1[1]==1?"red":"green")}} dangerouslySetInnerHTML = {{ __html:this.state.todayDataIcon1[1]==1?'&#8593;':'&#8595;' }}></span>
                                        <span className="dataVal">{this.state.dataVal1[1]}</span>                                    
                                    </div>                                                                
                                    <div className='todayDataInB'>
                                        <span style={{color:'black'}}>月</span>
                                        <span className="todayDataIcon" style={{color:(this.state.todayDataIcon1[2]==1?"red":"green")}} dangerouslySetInnerHTML = {{ __html:this.state.todayDataIcon1[2]==1?'&#8593;':'&#8595;' }}></span>
                                        <span className="dataVal">{this.state.dataVal1[2]}</span>                                    
                                    </div>
                                </div>
    

    其中dangerouslySetInnerHTML就是负责html展示的内容,同时该标签内不允许写入文字,只能在这个属性里写

    相关文章

      网友评论

          本文标题:React转义字符

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