我在渲染 TouchableOpacity 时遇到了一些问题
import React ,{Component} from 'react';
import {View, TouchableOpacity, Text} from 'react-native';
class Button extends Component {
render() {
return(
<TouchableOpacity onPress= {this.props.onPress}
style = {style.buttonStyle}>
<Text style = {style.textStyle}>{this.props.name}</Text>
</TouchableOpacity>
);
}
}
const style = {
textStyle:{
fontSize: 16,
alignSelf: 'center',
color: '#007aff',
fontWeight: '600',
paddingTop: 10,
paddingBottom: 10
},
buttonStyle: {
flex: 1,
alignSelf: 'stretch',
backgroundColor: '#000',
borderColor: '#007aff',
borderWidth: 1,
borderRadius: 5,
marginLeft: 5,
marginRight: 5
}
}
export {Button};