0%

使用umi搭建的后台系统的总结

对象转数组

1
2
3
4
5
6
7
<Select defaultValue="1">
{Object.keys(mealsType).map(n => (
<Option key={parseInt(n, 10)} value={parseInt(n, 10)}>
{mealsType[n]}
</Option>
))}
</Select>),

model.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export default {
namespace: 'manageuser',
state: {
manageUserList: {
val: [],
pagination: {
current: 1,
total: 0,
pageSize: 10,
},
},
roleList: []
},
effects: {

},
reducers: {

}

关于namespace的命名,一定要取全小写的,不可用驼峰式写法,要不会出现在model的方法不可调用的坑

mysql语法in

1
2
3
4
params = {};
let sql = 'from roos_user_config where type = 3';
sql += 'and no in (:canteens) ';
params.canteens = [ 'C0001', 'C0002' ];

JS字符串转数组,数组转字符串

1
2
3
4
//  数组转字符串
arr.split(',');
// 字符串转数组
str.join(',');

react-antd

1
2
3
4
5
6
7
// 当props发生变化时,触发此生命函数
componentWillReceiveProps(nextProps){
// eslint-disable-next-line react/destructuring-assignment
if (nextProps.userCanteens !== this.props.userCanteens) {
this.setState({ selectedRowKeys: nextProps.userCanteens})
}
}

-------------本文结束感谢你的阅读---------