标签类如下:
/**
* 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="我的收藏" />