首先创建RN工程,参照我的另一篇文章:创建RN工程
npm install @ant-design/react-native --save
npm add babel-plugin-import
// 遇到了几个错误:
npm install --save babel-preset-react-native@5
npm add @react-native-community/viewpager
npm add @react-native-community/slider
npm install --save @react-native-community/segmented-control
npm install @react-native-community/cameraroll --save
npm install @react-native-community/async-storage --save
import {Button, Provider, Toast} from '@ant-design/react-native';
<Provider>
<Button onPress={() => Toast.info('This is a toast tips')}>Antd</Button>
</Provider>
{
"plugins": [
["import", { libraryName: "@ant-design/react-native" }] // 与 Web 平台的区别是不需要设置 style
]
}