基于React 后台系统开发

设置

1
2
3
4
5
6
7
8
9
10
yarn create react-app test-admin
cd test-admin/
yarn add react-admin ra-data-json-server prop-types
yarn start
## 我采用如下方法,与上面一样
npm install -g create-react-app
create-react-app my-app
cd my-app/
npm add react-admin ra-data-json-server prop-types
npm start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  npm start
Starts the development server.

npm run build
Bundles the app into static files for production.

npm test
Starts the test runner.

npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

cd test-admin
npm start

与API建立连接

vi src/App.js

1
2
3
4
5
6
7
8
9
10
// in src/App.js
import * as React from "react";
import { Admin } from 'react-admin';
import jsonServerProvider from 'ra-data-json-server';

const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');

const App = () => <Admin dataProvider={dataProvider} />;

export default App;

参考

https://marmelab.com/react-admin/Tutorial.html

https://codesandbox.io/examples/package/ant-design-pro

文件夹结构:

https://pro.ant.design/zh-CN/docs/folder