react-native使用第三方库以及引入react-native-elements(十二)

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-17 08:12   78   0

react-native使用第三方库以及引入react-native-elements
1.首先需要下载依赖包到本地


cd /project
yarn add react-native-elements
# or with npm
npm install react-native-elements

2.引入react-native-elements到项目的component

User.js

以头像组件为例:

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

// Standard Avatar
<Avatar
  rounded
  source={{
    uri:
      'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg',
  }}
/>

// Avatar with Title
<Avatar rounded title="MD" />

// Avatar with Icon
<Avatar rounded icon={{ name: 'home' }} />

// Standard Avatar with edit button
<Avatar
  source={{
    uri:
      'https://s3.amazonaws.com/uifaces/faces/twitter/adhamdannaway/128.jpg',
  }}
  showEditButton
/>


做了一次搬运工,原始地址在这里:
https://react-native-elements.github.io/react-native-elements/docs/avatar.html

笔者用过这个做过一个完整的项目,相关的组件挺好用。提醒一下:不要过多依赖UI库,用react native + ES6实践,自己封装组件才能提高对框架的熟练度。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP