indexMes.js
954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";
import { connect } from "dva"; // 全局状态管理
import IndexMesComponent from "@/mes/indexMes";
export const IndexMesRoute = ({
dispatch,
app,
content,
sModelsId,
formRoute,
sModelType
}) => {
const props = {
app,
content,
dispatch,
sModelsId,
formRoute,
sModelType
};
return <IndexMesComponent {...props} />;
};
const mapStateToProps = props => props;
/* props:
{
'model1的namespace': 储存的值,
'model2的namespace': 储存的值,
...
}
因为在src/index.js 中引用的model 为app和content,所以这边返回的是
{
app: {...},
content: {...},
}
*/
// 用connect包装会默认传dispatch到组件中
// mapStateToProps会把返回的数据传到组件中(这里指app、content)
// 组件会收到dispatch+app+content+原来的参数(sModelsId,formRoute,sModelsType)
export default connect(mapStateToProps)(IndexMesRoute);