1用法
导入'react-native'组件如下:
(1)写法1
import {
Image,TextInput,
View,
Button,
Text,Alert,
StyleSheet
} from 'react-native';
(2)写法2
const ReactNative = require('react-native'); //定义导入地址
const {
Alert,
Button
} = ReactNative; //导入
Button
资料地址:https://github.com/reactnativecn/react-native.cn/blob/stable/docs/docs/0.39/button.md
简单实例:
/** * 方法 */ const logout = () => { Alert.alert('退出账户!'); }; export default class Personal extends Component { render() { return ( <View> <Button onPress={logout} title="退出账户" color="#841584" accessibilityLabel="Learn more about this purple button" /> </View> ); } }
原文链接:https://www.f2er.com/react/305140.html