配置RN环境+antdm蚂蚁金服界面库
本机都是在macos下操作
安装包
1
2
3
4
5
6
| brew install node
brew install watchman
brew install flow
npm install -g yarn
npm install -g react-native-cli
|
如果没有 Homebrew
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
配置
国内镜像
参考: https://npm.taobao.org/
1
| npm --registry https://registry.npm.taobao.org info underscore
|
1
| yarn config set registry https://registry.npm.taobao.org
|
创建项目
1
| react-native init myapp
|
过程漫长,请先
运行
第一次运行,自动配置项目环境,进行编译,时间会有点长,正常将看到
` 启动程序
调出
加入蚂蚁金服界面库
1
2
| yarn add antd-mobile
yarn add babel-plugin-import -dev
|
参考: https://github.com/ant-design/babel-plugin-import
1
2
3
4
| {
"presets": ["react-native"],
"plugins": [["import", { "libraryName": "antd-mobile", "style": true }]]
}
|
1
2
3
4
5
6
7
8
9
10
11
| import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { Button } from 'antd-mobile';
class HelloWorldApp extends Component {
render() {
return <Button>Start</Button>;
}
}
AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp);
|
在模拟器中
重新载入程序