一、建立 react-native 項目react
react-native init app03
二、安裝組件npm
npm install antd-mobile-rn --save
三、配置按需加載react-native
npm install babel-plugin-import --save-dev // .babelrc 文件中增長下面代碼 "plugins": [ [ "import", { "libraryName": "antd-mobile-rn" } ] ]
四、使用 antd-mobile-rn 組件進行開發babel
App.jsantd
import React, {Component} from 'react'; // 導入組件 import { Button } from 'antd-mobile-rn'; type Props = {}; export default class App extends Component<Props> { render() { return ( <View style={styles.container}> // 使用組件 <Button type='primary'>按鈕</Button> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', } });
展現效果:app