• React Native(七)——react-native-elements


    配合React native使用的UI库:https://react-native-training.github.io/react-native-elements/

    1. 新建项目:http://www.cnblogs.com/zhengyeye/p/7567509.html(不赘述了)

    2. 执行 react-native run-android 安装app在手机或者模拟机上;突然才发现RN版本升级后,项目目录结构变得更简洁了

    clip_image001

    clip_image003

    新版的为用户节省了很多工作,将整个逻辑代码合并在一个App.js中,省去了用户自己新建项目的必要。

    安装方法:

    Step 1: Install react-native-vector-icons¶
    
    npm i react-native-vector-icons --save && 
    
    react-native link react-native-vector-icons
    
    Step 2: Install react-native-elements¶
    
    yarn add react-native-elements or
    
    npm i react-native-elements --save

    使用方法(使用什么组件,便引入其就可):

    import { Button } from 'react-native-elements';

    部分组件——

    1.button(按钮):

    onPress:用法类似于RN中button的用法,这种也是定义一个函数;

    export default class App extends Component<{}> {
        _onPress = () => {
            alert('dianji');
        };
        render() {
            return (
                <View style={styles.container}>
                    <Button
                        raised
                        icon={{ name: 'home', size: 32 }}
                        buttonStyle={{ backgroundColor: 'red', borderRadius: 10 }}
                        textStyle={{ textAlign: 'center' }}
                        onPress={this._onPress}
                        title={`Welcome to
    React Native Elements`}
                    />
               </View>
           )
    }
    ...

    2.Avatar(头像):

    限制头像大小:

    small  medium large xlarge

    rounded:默认为false(矩形),定义头像的形状,为ture则为圆形;
    若想在头像中自定义图片,则有两种方法:
    ... 
        icon={{name: 'rocket', color: 'orange'}}  //通过icon属性设置
    ...
    ...
        source={{ uri: 'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg' }}//通过类似于<Image />的source属性来定义
    ...
    overlayContainerStyle:定义图片之外视图的颜色;
    onPress:用法同button;
    containerStyle:定义整个容器的外部样式,比如宽高怎样的;
    3.Badge(徽章,类似于聊天中未读消息右上角的阅读数):
    ……

    很多组件,还是需要慢慢了解的~~~

  • 相关阅读:
    Leetcode424. 替换后的最长重复字符
    Leetcode82. 删除排序链表中的重复元素 II
    python 无序模块,hashlib模块
    python 内置方法
    python 面向对象的三大特性
    python 面向对象
    python 递归函数和二分查找
    python 装饰器
    python 函数名,闭包
    python 函数进阶
  • 原文地址:https://www.cnblogs.com/zhengyeye/p/7716301.html
Copyright © 2020-2023  润新知