阿里開源的前端框架Ant-Design-Mobile可以支持react-native和react-web項目開發(fā),是一套比較成熟的UI框架樟遣,我們采用這套框架來搭建一個react-native項目雕憔。
1)建立一個react-native的標(biāo)準(zhǔn)項目
$ react-native init AntdMobileDemo
$ cd AntdMobileDemo
$ react-native run-ios
啟動下ios模擬器驗證下姿骏。
2)添加Ant-Design-Mobile相關(guān)依賴
$ yarn add antd-mobile
$ yarn add babel-plugin-import --dev
3)配置文件修改
.babelrc文件增加一行配置
"plugins": [["import", { "libraryName": "antd-mobile" }]]
4)代碼修改
index.ios.js
import { Button } from 'antd-mobile';
<Button>antd-mobile button</Button>
5)效果查看
image.png