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\nReact 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(徽章,类似于聊天中未读消息右上角的阅读数):
……

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值