转换之前务必全转为小写
var fieldName = field.eFieldName.toLowerCase();
调用方法
var newFieldName = fieldTrans(fieldName);
方法
function fieldTrans(field){
var resultField = field;
if(field!=null){
var splitIndex = field.indexOf("_");
if(splitIndex>-1){
var beforeLetter = field.substring(0,splitIndex);
var firstLetter = field.substring(splitIndex+1,splitIndex+2);
var afterLetter = field.substring(splitIndex+2,field.length);
var fLetter = firstLetter.toUpperCase();
resultField = beforeLetter+fLetter+afterLetter;
if(resultField.indexOf("_")>-1){
resultField = fieldTrans(resultField);
}else{
return resultField;
}
}
}
return resultField;
}