开发者社区> 问答> 正文

ios,iconfont不显示

IMG_0255

render() {

    const {style,textStyle,iconStyle,showIcon,icon,width} = this.props;
    let textWrapStyle=width?{width:width,textAlign:"right"}:{};
    let iconElem=String(showIcon).toLowerCase() ==="true"?(<Icon style={{width:'30rem',height:'30rem',marginLeft:'10rem'}} name='arrowDown' />):{};
    return(
        <TouchableHighlight onPress={this.pressHandler.bind(this)} value="" style={[sty.dropdown,style]}>
          <view style={textWrapStyle}>
            <Text style={[{fontSize:"28rem",color:"#666666",lines:1,textOverflow:'ellipsis'},textStyle]} textOverflow="true">{this.state.text}</Text>
          </view>
          {iconElem}
        </TouchableHighlight>);
}

iconfont问题

import {createElement, Component,render} from 'rax';
import { View, Text, TouchableHighlight, Modal,Picker,Icon,Iconfont} from 'nuke';
import {Enum} from 'common/dp/index.jsx';
import sty from "./index.less"

class Dropdown extends Component {

constructor(props) {
    super(props);
    Iconfont({name:"iconfont1",url:"http://at.alicdn.com/t/font_1474198576_7440977.ttf"});
    //初始化属性值
    this.props.value=String(this.props.value);
    let current=null;
    //source 提出警告
    if(!props.source.length){
      throw new Error("warning:source is null")
    };
    this.enum=new Enum;
    this.state = {}
    //设置数据
    this.setData(props);
}
setData(props){
  this.enum.setEnum("source",props.source);
  let current= props.value!=null?this.enum.getItemByKey("source",props.value):{};
  this.state.text =current&&current.value;
  this.state.value =current&&current.key;
}

static defaultProps = {
   name:"",
   source: [],
   value: null,
   onChange:(e)=>{ console.log("change")},
   style:{},
   showIcon:true,
       icon:"arrowDown",
   textStyle:{},
   iconStyle:{},
   width:null
}
pressHandler(){
  var self=this;
  Picker.show({title:'请选择',dataSource:this.props.source,maskClosable:true,selectedKey:this.state.value},
  function(data){
      let result=data.length&&data[0];
      if(self.state.value!=result.key){
        self.props.onChange(result)
      }
      self.setState({value:result.key,text:result.value})
  });
}
render() {
    const {style,textStyle,iconStyle,showIcon,icon,width} = this.props;
    let textWrapStyle=width?{width:width,textAlign:"right"}:{};
    let iconElem=String(showIcon).toLowerCase() ==="true"?(<Icon style={{width:'30rem',height:'30rem',marginLeft:'10rem'}} name='arrowDown' />):{};

    let item= {"icon":"\ue600","name":"直播"};
    return(
        <TouchableHighlight onPress={this.pressHandler.bind(this)} value="" style={[sty.dropdown,style]}>
          <view style={textWrapStyle}>
            <Text style={[{fontSize:"28rem",color:"#666666",lines:1,textOverflow:'ellipsis'},textStyle]} textOverflow="true">{this.state.text}</Text>
          </view>
          {iconElem}
            <View style={style.iconCell}>
                <Text style={style.icon1}>{item.icon}</Text>
                <Text style={style.iconCellText}>{item.name}</Text>
            </View>
        </TouchableHighlight>);
}

componentWillReceiveProps(nextProps){
  this.setData(nextProps);
  this.setState({});
}

}

const style={

iconCell:{
    paddingLeft:'40rem',
    paddingRight:'40rem'
},
icon1:{
    fontFamily: 'iconfont1',
    fontSize: '36rem',
    marginBottom:'40rem',
    color:'blue',
    alignItems:'center'

},
iconCellText:{
    fontSize: '20rem',
    color:'#999999',
    alignItems:'center'
}

}

export default Dropdown;

展开
收起
a6bfe36a7a3 2017-05-03 10:07:10 6257 0
1 条回答
写回答
取消 提交回答
  • 首先排查 Iconfont({name:"iconfont1",url:"http://at.alicdn.com/t/font_1474198576_7440977.ttf"}); iconfont项目汇总是否有\ue600这个图标,是否是最新地址。看现象应该是图标没加载到,建议刷新看看

    2019-07-17 21:07:54
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载