React-Native:TouchableOpacity渲染问题

时间:2017-11-06 17:31:04

标签: react-native touchableopacity

渲染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};

这是我的按钮组件的代码,我的按钮在渲染时看起来像这样 The Button

我在登录组件中使用了相同的组件,它工作得很好...... 预期按钮 This is the button which i expect to render

0 个答案:

没有答案