javascript - Is there a simple way to write it?
我想大声告诉你
我想大声告诉你 2017-05-19 10:27:40
0
4
559

styleArr = data.items[0].companys_self_type_styleid.split(',')
matArr = data.items[0].companys_self_type_matid.split(',')
fieldArr = data.items[0 ].companys_self_type_fieldid.split(',')

Is there a simple way to write it

我想大声告诉你
我想大声告诉你

reply all(4)
过去多啦不再A梦
[styleArr, matArr, fieldArr] = [styleArr, matArr, fieldArr].map((key, index) => 
data.items[0]["companys_self_type" + [
    "styleid", "matid", "fieldid"
][index]].split(','))
大家讲道理
function deal(n){
return data.items[0].n.split(',')
}
styleArr = deal(companys_self_type_styleid);
matArr = deal(companys_self_type_matid);
fieldArr = deal(companys_self_type_fieldid);
为情所困
var data = {};
for (var prop in data.items[0]) {
  var i = prop.substring(prop.lastIndexOf('_') + 1, prop.lastIndexOf('id')) + 'Arr';
  data[i] = data.items[0][prop].split(',');
}
黄舟

var arr = data.items[0].companys_self_type_styleid.split(',');
var styleArr,matArr,fieldArr
styleArr = matArr = fieldArr = arr ;

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template