【发布时间】:2023-04-01 10:20:01
【问题描述】:
我们可以使用单个关键字而不是'' import { Text, TextInput, Button, StyleSheet, View } from 'react-native'; ” 在 react native 中?“Text、TextInput、Button、StyleSheet、View”是否有可用的 Single 关键字选项?
import { Button, StyleSheet, View } from 'react-native';
export default class ButtonBasics extends Component {
_onPressButton() {
alert('You tapped the button!')
}
render() {
return (
<View style={styles.container}>
<View style={styles.buttonContainer}>
<Button
onPress={this._onPressButton}
title="Press Me"
color="#841584"
/>
</View>
<View style={styles.alternativeLayoutButtonContainer}>
<Button
onPress={this._onPressButton}
title="This looks great!"
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
buttonContainer: {
margin: 20
},
alternativeLayoutButtonContainer: {
margin: 20,
flexDirection: 'row',
justifyContent: 'space-between'
}
});
【问题讨论】:
标签: react-native react-component