小编bar*_*eek的帖子

如何在React Native中添加按钮?

我对这整个"没有CSS"的东西感到困惑,但我理解为什么它有益.我想要做的只是在屏幕中间放置一个按钮,但我不明白样式在React中是如何工作的.这是我的代码:

var tapSpeed = React.createClass({
  render: function() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Tap me as fast as you can!
        </Text>
        <View style={styles.button}>
        !
        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#FFCCCC'
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10
  },
  button: {
    textAlign: 'center',
    color: '#ffffff',
    marginBottom: 7,
    border: 1px solid blue,
    borderRadius: 2px
  }
});
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native

43
推荐指数
3
解决办法
8万
查看次数

标签 统计

javascript ×1

react-native ×1

reactjs ×1