很不错的button组件
https://github.com/ide/react-native-button
安装:
1 |
npm install react-native-button --save |
导入:
1 |
import Button from 'react-native-button' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import React, { Component } from 'react'; import Button from 'react-native-button'; export default class ExampleComponent extends Component { constructor(props, context) { super(props, context); } _handlePress() { console.log('Pressed!'); } render() { return ( <Button style={{fontSize: 20, color: 'green'}} styleDisabled={{color: 'red'}} onPress={() => this._handlePress()}> Press Me! </Button> ); } }; |
容器样式:
1 2 3 4 5 |
<Button containerStyle={{padding:10, height:45, overflow:'hidden', borderRadius:4, backgroundColor: 'white'}} style={{fontSize: 20, color: 'green'}}> Press me! </Button> |