react-native控件

来源:互联网 发布:excel网页数据抓取vba 编辑:程序博客网 时间:2024/05/19 18:14

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>
        );
 }
}












0 0
原创粉丝点击