react-native 给标签传图片地址

标签类如下:

/**
 * lutn 2017-01-05
 * 横条按钮
 * 
 */
import React, { Component } from 'react';
import {StyleSheet, Text, View, TouchableOpacity,Image } from 'react-native';

export default class RowButton extends Component{
  constructor(props){
      super(props);
      this.state={
        disabled:false,
      }
  }
  /**
   * 事件
  */
  _onPress = () =>{
    const {onPress} = this.props;
    if ( onPress != null) {
      onPress(this._enable);
    }
  }

  /**
   * 禁用
  */
  _enable = () =>{
      this.state={
        disabled:false,
      }
  }
  /**
   * 启用
  */
  _disable = () => {
      this.state={
        disabled:true,
      }
  }
  render() {
    let {url,text} = this.props;
    console.log("url="+url);
    return (
        
   
   
            
    
    
                
     
     
                
     
     
                    
      
      
                        
       
        
         
       
                    
      
      
                    
      
      
                        
       
        
        
          {text} 
         
       
                        
                    
      
      
                
     
     
                
     
     
                
                
     
     
    
            
    
    
        
   
   
    )
  }
}
const styles = StyleSheet.create({
    buttonViw:{
        backgroundColor:'white',
        flexDirection: 'row', 
        flex:1,
        height:50,        
    },
    b1:{
        flex:1,
        // backgroundColor:'#ffff00',
    },
    b2:{
        flex:14,
        // backgroundColor:'#ffff00',
        flexDirection: 'row',
        borderBottomColor:'#f5f4f2',
        borderBottomWidth:1,
    },
    n1:{
        flex:2,
        // backgroundColor:'#99ff00',
        justifyContent:'center',
        alignItems:'center',
    },
    n2:{
        flex:12,
        justifyContent:'center',
    
        // backgroundColor:'#33ffff',
    },
    b3:{
        flex:1,
        // backgroundColor:'#cc00cc',
    },
    button:{
        flexDirection: 'row',
        flex:1, 
    },
    disabled:{
        backgroundColor:'gray',
    },
});

上面的重点代码如下:

let {url,text} = this.props;

<Image style={{height:30,width:30}}  source={url} />

<Text>{text}</Text>

使用:

<RowButton url={require("../../images/personal/Collection.png")} text="我的收藏" />



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hi竹子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值