React-Learning-day05

Ant 蚂蚁框架

安装使用:

1
2
3
4
5
6
//通过cnpm全局安装create-react-app命令
cnpm install -g create-react-app
//使用create-react-app命令创建名为reactapp的app应用
create-react-app reactapp
//安装蚂蚁的移动UI
cnpm install antd-mobile --save

全部导入样式和js:

1
2
import { Button } from 'antd-mobile';
import 'antd-mobile/dist/antd-mobile.css';

按需要导入(手动引入):

1
2
import DatePicker from 'antd-mobile/lib/date-picker';  // 加载 JS
import 'antd-mobile/lib/date-picker/style/css'; // 加载 CSS

按需要导入(安装插件方式):
1、安装插件:

1
cnpm install babel-plugin-import --save

2、配置:
npm命令

1
2
3
4
5
6
显性化各种依赖配置信息:
git init
git add .
git commit -m "Saving before ejecting"

npm run eject

Packjson

1
2
3
4
5
6
7
8
"babel": {
"presets": [
"react-app"
],
"plugins": [
["import", { "libraryName": "antd-mobile", "style": "css" }]
]
}

项目数据:
1、数据导入
将json文件导入到数据库。创建数据库,右键点击表,选择导入文件,文件导入json文件,点击完成。
2、创建服务器
npm init
cnpm install express –save
cnpm install mysql –save
创建index.js文件
3、前端依赖
需要安装的内容:
axios
react-router-dom
react-redux