fix: 弃用Object.entries方法

This commit is contained in:
wenbo.dong 2017-10-12 18:36:59 +08:00
parent 250e2e5485
commit f734b3a3ed
2 changed files with 15 additions and 6 deletions

View File

@ -86,12 +86,12 @@ exports.simpleJsonPathParse = function (key, json){
try{
let m = keys[i].match(/(.*?)\[([0-9]+)\]/)
if(m){
json = json[m[1]][m[2]];
json = json[m[1]][m[2]];
}else{
json = json[keys[i]];
json = json[keys[i]];
}
}catch(e){
json = null;
break;
@ -166,3 +166,12 @@ exports.nameLengthLimit = (type) => {
}
}]
}
// 实现 Object.entries() 方法
exports.entries = (obj) => {
let res = [];
for(let key in obj) {
res.push([key, obj[key]]);
}
return res;
}

View File

@ -11,7 +11,7 @@ const RadioGroup = Radio.Group;
const RadioButton = Radio.Button;
import constants from '../../../../constants/variable.js';
const confirm = Modal.confirm;
import { nameLengthLimit } from '../../../../common';
import { nameLengthLimit, entries } from '../../../../common';
import '../Setting.scss';
// layout
const formItemLayout = {
@ -164,7 +164,7 @@ class ProjectMessage extends Component {
const { name, basepath, desc, project_type } = projectMsg;
initFormValues = { name, basepath, desc, project_type };
const colorArr = Object.entries(constants.PROJECT_COLOR);
const colorArr = entries(constants.PROJECT_COLOR);
const colorSelector = (<RadioGroup onChange={this.changeProjectColor} value={projectMsg.color} className="color">
{colorArr.map((item, index) => {
return (<RadioButton key={index} value={item[0]} style={{ backgroundColor: item[1], color: '#fff', fontWeight: 'bold' }}>{item[0] === projectMsg.color ? <Icon type="check" /> : null}</RadioButton>);