React-Native 使用第三方 UI

2022-09-08  本文已影响0人  游园拾忆

一、react-native-elements

  1. 官网:https://reactnativeelements.com/
  2. 安装。
npm install react-native-elements
npm install react-native-vector-icons
npm install react-native-safe-area-context
# 使用最新版,可能会版本冲突。如果报错,提示里有可用版本。
npm install react-native-safe-area-context@3.4.1
npx react-native link react-native-vector-icons
npx react-native link react-native-safe-area-context
import { SafeAreaProvider } from 'react-native-safe-area-context';

function App() {
  return <SafeAreaProvider>...</SafeAreaProvider>;
}
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
import AntDesign from 'react-native-vector-icons/AntDesign';
import {Button} from 'react-native-elements';


<AntDesign name="addusergroup" size={20} color={'#00ff00'} />
<Button
  title="Loading button"
  loading
/>
<Button
  icon={<AntDesign name="addusergroup" size={15} color="white" />}
  title="带蚂蚁图标的按钮"
  buttonStyle={{width: 100}}
/>


二、antd-mobile-rn

  1. 官网:https://rn.mobile.ant.design/index-cn
  2. 安装
npm install antd-mobile-rn --save
  1. 按需加载组件功能
npm install babel-plugin-import --save-dev
module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'import',
      {
        libraryName: 'antd-mobile-rn',
      },
    ],
  ],
};
上一篇 下一篇

猜你喜欢

热点阅读