Sha*_*mal 6 react-native react-component
我们可以使用单个关键字而不是 '' import { Text, TextInput, Button, StyleSheet, View } from 'react-native'; “在本机反应中?对于“文本、文本输入、按钮、样式表、视图”,是否有可用的单关键字选项?
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'
}
});
Run Code Online (Sandbox Code Playgroud)
您可以import ReactNative from 'react-native'使用它们<ReactNative.View/>等等,但我不建议这样做。这不是 99% 的 RN 开发人员所期望的阅读方式。
| 归档时间: |
|
| 查看次数: |
81 次 |
| 最近记录: |