Maison > Questions et réponses > le corps du texte
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( ',')
Y a-t-il un moyen simple de l'écrire
过去多啦不再A梦2017-05-19 10:29:40
[styleArr, matArr, fieldArr] = [styleArr, matArr, fieldArr].map((key, index) =>
data.items[0]["companys_self_type" + [
"styleid", "matid", "fieldid"
][index]].split(','))
大家讲道理2017-05-19 10:29:40
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);
为情所困2017-05-19 10:29:40
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(',');
}
黄舟2017-05-19 10:29:40
var arr = data.items[0].companys_self_type_styleid.split(',');
var styleArr,matArr,fieldArr
styleArr = matArr = fieldArr = arr ;