Récemment, j'ai créé un système de gestion des utilisateurs, qui a des exigences de projet et nécessite l'utilisation de JS pour générer un formulaire avec indentation. C'est vraiment moi-même. Cette fonction est réalisée en recherchant des informations pertinentes. L'éditeur suivant apporte des notes au code d'implémentation, ce qui est pratique pour les recherches futures. En même temps, j'espère aussi que les amis qui ont les mêmes besoins que moi pourront faire une référence. S'il y a une meilleure méthode, laissez-moi un message, merci!
JS fait le formulaire suivant:
json
[ot Informations "," valeur ":" "," comment ":" "," Parentid ": - 1," ChildrenParam ": [{" id ": 305," ServiceId ": 15," Name ":" info "," type ":" jsonObject "," Paramdesc ":" Query Contenu "," Value ":" "," comment ":" "," Parentid ": 302," ChildrenParam ": [{" id ": 312," Service Id ": 15," Name ":" entinvlist "," type ":" list "," Paramdesc ":" Enterprise Foreign Investment Foreign Investment Situation "," Value ":" "," comment ":" "," Parentid ": 305," ChildrenParam ": [{" id ": 343," serviceID ": 15," Name ":" Regno "," Type ":" String "," Paramdesc ":" Regregistration Number "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": NULL}, {" ID ": 342," ServiceId ": 15," Name ":" R Egcapcur "," Type ":" String "," Paramdes ":" Enregistré en capital enregistré en capital Currency "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 341," serviceID ": 15," name ":" regcap "," type ":" String "," Paramdesc ":" regcap (10000 "," Yuan), "Value": "", "comment": "", "Parentid": 312, "ChildrenParam": null}, {"id": 340, "serviceID": 15, "name": "ent_nam e", "type": "String", "Paramdesc": "Représentatif juridique Nom "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 339," serviceId ": 15," name ":" FunDedratio "," Type ":" String "," Paramdesc ":" Contribution Ratio "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 338," serviceID ": 15," name ":" esdate "," type e ":" string "," paramdesc ":" ouverture Date "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 337," serviceID ": 15," name ":" error "," type ":" String "," ParamDesc ":" Abondié Capital (10 000 Yuan) "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 336," serviceID ": 15," name ":" Enttype "," type ":" strin g "," paramdes ":" Entype ") Type "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 345," serviceId ": 15," name ":" Revdate "," type ":" String "," Paramdesc ":" Revod Date "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 344," serviceId ": 15," Name ":" Regorg "," type ":" String "," Paramd ESC ":" Enregistrement Autorité "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 334," serviceID ": 15," Name ":" Currency "," Type ":" String "," Paramdesc ":" Abonda en capital Currency "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 335," serviceID ": 15," name ":" Entstatus "," type ":" String "," entcompy ":" entendentStatus " Status "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 333," serviceId ": 15," name ":" Candate "," Type ":" String "," Paramdesc ":" Connexion " Date "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}]}, {" id ": 346," serviceID ": 15," name ":" ent_name "," type ":" String "," Paramdes ":" ent name "," value " ":" "," comment ":" "," parentid ": 305," ChildrenParam ": null}, {" id ": 311," serviceId ": 15," name ":" basic "," type ":" jsonObject "," paramdes ":" Basic Informations "," valeur ":" "," comment ":" "," Parentid ": 305," ChildrenParam ": [{" id ": 326," serviceID ": 15," name ":" opscope "," type ":" string "," paramdesc ":" business (business) scope "," value ":", "com": "comte ment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 327," serviceID ": 15," nom ":" opto "," type ":" string "," paramdesc ":" Terme d'opération vers Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 324," serviceId ": 15," name ":" IndustryPhy "," type ":" string "," paramdes ":" National Economic Industry Code "," value ":" "," "", "" "" Commentaire ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 325," serviceID ": 15," name ":" Opfrom "," type ":" String "," Paramdesc ":" Le terme d'opération est à partir de Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 322," serviceId ": 15," name ":" frname "," type ":" string "," paramdesc nommé "," valeur ":", "comment": "", "Parentid": 311, "ChildrenParam": null}, {"id": 323, "serviceID": 15, "nom": "industrieco", "type": "string", "paramdesc": "catégorie de l'industrie Code "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 320," serviceID ": 15," name ":" EntType "," type ":" String "," Paramdesc ":" Entreprise (institution) Le type de responsabilité, les sociétés de responsabilité limitée, les sociétés à responsabilité limitée, les sociétés à responsabilité limitée, les sociétés à responsabilité limitée, les sociétés à responsabilité limitée, les sociétés à responsabilité limitée, etc. "," Value ":", "comment": "", "parentid": 311, "ChildrenParam": null}, {"id": 321, "serviceId": 15, "name": "esdate", "type": "String", "Paramdesc": "Date d'ouverture Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 332," serviceId ": 15," name ":" revdate "," type ":" string "," paramdesc ":" révoqué la date Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 330," serviceId ": 15," name ":" regno "," type ":" string "," paramdes ":" Enregistrement " Numéro "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": Null}, {" id ": 331," ServiceD ": 15," Name ":" Regorg "," Type ":" String "," Paramdesc ":" Inscription Authority "," Va lue ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 328," serviceID ": 15," name ":" regcap "," type ":" String "," Paramdesc ":" Enregistrement d'unité de capital: 10 000 Yuan "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 329," serviceId ": 15," name ":" regcapcur "," type ":" String "," paramdes ":" Currency RMB, usollar, etc. "," Valulu " E ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 313," serviceID ": 15," name ":" opscoandform "," type ":" String "," Paramdesc ":" Scope et méthode de fonctionnement (Business) "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 315," serviceID ": 15," nom ":" ancheyear "," type ":" string "," paramdesc ":" dernière inspection annuelle yyyyyyy "," valeur ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 314," serviceID ": 15," name ":" abusitem "," type ":" String "," Paramdesc ":" licence commerciale licenciée Project "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 317," ser viced ": 15," name ":" cbuuitem "," type ":" String "," Paramdesc ":" General Business " Project "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 316," serviceId ": 15," name ":" Candate "," type ":" String "," Paramdesc ":" Logout Date yyyy-mm-dd "," val ue ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 319," serviceId ": 15," name ":" Entstatus "," type ":" String "," Paramdesc ":" Statut de fonction Autre "," valeur ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 318 , "ServiceId": 15, "Name": "Dom", "Type": "String", "Paramdesc": "Address", "Value": "", "Comment": "", "Parentid": 311, "ChildrenParam": null}]}]}, "Type": "String", "String", ":" Name ":" Result "," Type " Résultat "," Valeur ":" Match | not_match | Not_found "," comment ":" "," parentid ": 302," ChildrenParam ": null}, {" id ": 303," serviceId ": 15," name ":" status "," type ":" booléen "," paramdes ":" retour interface return " Status "," Value ":" "," comment ":" "," Parentid ": 302," ChildrenParam ": null}]}, {" id ": 306," serviceId ": 15," name ":" API_STATUS "," Type ":" JSONOBJECT "," Paramdesc ": RETOUR Code "," Value ":" "," comment ":" "," Parentid ": - 1," ChildrenParam ": [{" id ": 307," serviceID ": 15," name ":" status "," type ":" booléen "," paramdes ":" Interface Return Status "," Value ":" "," comment ":", "pare Interface" ntid ": 306," ChildrenParam ": null}, {" id ": 309," serviceID ": 15," name ":" Description "," type ":" String "," Paramdesc ":" Return Status Description "," Value ":" "," comment ":" "," Parentid ": 306," ChildrenParam ": null}, {" id ": 308," serviceID ": 15," name ":" code "," type ":" stage "," Paramdesc ":" Status " Code "," Value ":" "," comment ":" "," Parentid ": 306," ChildrenParam ": null}, {" id ": 310," serviceID ": 15," name ":" serial_no "," type ":" String "," Paramdesc ":" Flow Numéro "," valeur ":" "," comment ":" "," Parentid ": 306," ChildrenParam ": null}]}]js
// Paramètre de sortie de la page API Description var apitohtml_outparamfn = fonction (json, returnExample) {var html = '' var mustarr = ['required', 'optional'] var paramhtml = '' var data = $ .parsejson (json); console.log (data) // Name: paramètre name // type: paramètre type // paramètre: paramètre: paramètre pueter name // Type: Paramet Type // Paramder: paramètre: Paramètre Name // Type: Paramet Type // Paramder: Paramter: Donter: Parameter Name // Type: Paramet Type // Paramder: Paramter Deconte Affectation Description // Commentaire: Paramètre Autre Description // ChildrenParam: Liste des paramètres de l'enfant console.log ('----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- c = [] dataformatfn2 (data, flaghi) // statistiques Le nombre de sous-classes // chaque nœud ajoute l'attribut LEN pour compter la somme du nœud enfant et la fonction de nœud enfant DataFormatfn2 (data) {for (var i = 0; i <data.length; i ++) gens data.childrenparam.length) || 1 // Debugger // console.log (data) c = c || [] if (data.childRenparam) {for (var i = 0; i <data.childrenare.length; i ++) {b ++ data.len + = dataformatfn (data.childrenParam [i], Flati + 1, b, c [i]); data.len} else {return (data.childRenparam && data.childrenparam.length) || 0}} console.log (bbb) console.log (data) var flaghi = 0 // après le passage à DataFormatafn2, exécution // paramhtml = jontohtml (data); paramhtml = ''; var nbsparr = ['', '<b> ⅰ </b>', '<b> ⅱ </b>', '<b> ⅲ </b>', '<b> ⅵ </b>', '<b> ⅴ </b>', ',' <b> ⅵ </b> ',' <b> ⅶ </b> ',' <b> ⅷ </b> ',' <b> ⅸ </b> ',' <b> ⅹ </b> '] pour (var i = 0; i <data.length; i ++) {var str2 = '' var span = 1if (i == 0 && flaghi> 0 && len> 1) {span = (10-flagi) str2 = '<td Rowspan = "' + (len) + '"> </ td>'} else {span = (10-flagi)} paramhtml + = '+ / span = sttre + '/ <td colspan = "' + span + '"> <nobr>' + nbsparr [laghi] + data [i] .name + '</br> </td> / <td>' + data [i] .type + '</td> / <td>' + data [i] .paramdes + '</td> / <td>' + data [i]. + '</td> / <td>' + data [i] .comment + '</td> / </tr>' if (data [i] .childRenparam) {paramhtml + = jSontohtml (data [i] .childrenparam, flami + 1, data [i] .len)} else {Flati}} return return paramHtml}console.log('--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Colspan = "10"> <Nobr> Paramètre Nom de l'anglais </ NOBR> </ TH> / <TH> <NOBR> Type de paramètre </COBR> </ TH> / <TH> <NOBR> Définition chinoise </brr> </th> / <Th> <NOBR> Affectation de paramètre Description </br> </th> / <Th> <Notr> Autre Instructions </ nobr> </ th> / </tr> / </thead> / <tbody> / '+ paramhtml +' / </pody> / </s table> / </div> / </dd> '$ (' # outparam dl '). html (html);} html <! doctype html> Charset = "UTF-8"> <Title> JS génère une table intentée </ title> </ head> <body> <div id = "outParam"> <dl> </dl> </div> </ body> </html> Code complet: <! DocType Html> <html Lang = "en"> <éread table </ title> <link rel = "Stylesheet" type = "text / css" media = "screen" href = "http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css"> </ head> </ body> <div id = "outparam"> <dl> / dl> src = "http://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"> </ script> <cript> var json = '[{"id": 302, "Serviced": 15, "name": "data", "type": "jsonobject", "paramdesc": "return Query" Informations "," valeur ":" "," comment ":" "," Parentid ": - 1," ChildrenParam ": [{" id ": 305," ServiceId ": 15," Name ":" info "," type ":" jsonObject "," Paramdesc ":" Query Contenu "," Value ":" "," comment ":" "," Parentid ": 302," ChildrenParam ": [{" id ": 312," Se Rviceid ": 15," Name ":" Entinvlist "," Type ":" List "," Paramdesc ":" Enterprise Foreign Investment Situation "," Value ":" "," comment ":" "," Parentid ": 305," ChildrenParam ": [{" id ": 343," serviceID ": 15," Name ":" Regno "," Type ":" String "," Paramdesc ":" Regregistration Numéro "," valeur ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 342," serviceId ": 15," Nam e ":" regcapcur "," type ":" string "," paramdesc ":" regcapcurrent "," value ":" "," comment ":" "," parentid ": 312," knidsparam ": null}, {" id ": 341," serviced ": 15," name ":" regcap "," type ":" string "," paramdesc ":" Crecap " Yuan), "Value": "", "comment": "", "Parentid": 312, "ChildrenParam": null}, {"id": 340, "serviceID": 15, "name": "en t_name", "type": "String", "Paramdes": "Représentant légal Nom "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 339," serviceId ": 15," name ":" FunDedratio "," Type ":" String "," Paramdesc ":" Contribution Ratio "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 338," serviceId ": 15," name ":" esdate "," type ":" String "," Paramdesc ":" Open " Date "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 337," serviceID ": 15," name ":" error "," type ":" String "," ParamDesc ":" Abondié Capital (10 000 Yuan) "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 336," serviceID ": 15," name ":" EntType "," type ":" S Twist "," Paramdes ":" Enterprise (institutional) Type "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 345," serviceId ": 15," name ":" Revdate "," type ":" String "," Paramdesc ":" Revod Date "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 344," serviceId ": 15," name ":" Regorg "," type ":" String "," Pa Ramdesc ":" S'inscription Autorité "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 334," serviceID ": 15," Name ":" Currency "," Type ":" String "," Paramdesc ":" Abonda en capital devise "," valeur ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}, {" id ": 335," serviceID ": 15," name ":" Entstatus "," type ":" String "," Paramdesc " : "ent_name", "type": "paramdesc": "", "parentid": 312, "ChildrenParam": null}, {"id": 333, "serviceId": 15, "name": "camé", "type": "string", "paramdes": "Connexion" Date "," Value ":" "," comment ":" "," Parentid ": 312," ChildrenParam ": null}]}, {" id ": 346," serviceID ": 15," name ":" ent_name "," type ":" string "," paramdes ":" ent name "," VA " lue ":" "," comment ":" "," Parentid ": 305," ChildrenParam ": null}, {" id ": 311," serviceID ": 15," name ":" Basic "," type ":" jsonObject "," Paramdesc ":" Enterprise Informations "," valeur ":" "," comment ":" "," Parentid ": 305," ChildrenParam ": [{" id ": 326," serviceID ": 15," name ":" opscope "," type ":" String "," Paramdesc ":" Operation (entreprise) Scope "," valeur ":", "C". oment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 327," serviceID ": 15," name ":" opto "," type ":" string "," paramdes ":" Terme d'opération à Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 324," serviceId ": 15," name ":" industryPhy "," type ":" string "," paramdes ":" industrie nationale économique nationale " Code "," valeur ":" "" "" "" "" Valeur ": """"mée aller la planche""mée"""mée le la gueulemée aller "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ". "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ". "" "" "" "" "" "" "" "" "" "" "" "" "" " , "Comment": "", "parentid": 311, "ChildrenParam": null}, {"id": 325, "serviceId": 15, "name": "opfrom", "type": "string", "paramdes": "le terme d'opération est de partir de Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 322," serviceId ": 15," nom ":" Frnname "," type ":" String "," ParamDesc ":" déterminé comme le nom du dernier, l'Enterprise est le représentant légal, et le nom de la personne dans le dernier, l'Enterprise est le représentant légal, et le nom de la personne dans le dernier, l'Enterprise est le représentant légal, et la personne à la personne dans le dernier, l'Enterprise est le représentant légal, et la personne à la personne dans le dernier, l'Enterprise est le représentant légal, et la personne dans la personne dans le dernier, l'Enterprise est le représentant légal, et la personne à la personne dans le dernier, l'Enterprise est le représentant légal, et la personne à la personne dans le dernier, l'Enterprise est Nom "," Value ":" "," Comment ":" "," Parentid ": 311," ChildrenParam ": NULL}, {" ID ": 323," ServiceId ": 15," Name ":" IndustryCo "," Type ":" String "," ParamDesc ":" Catégorie de l'industrie Code "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 320," serviceID ": 15," name ":" EntType "," type ":" String "," Paramdesc ":" Entype (institution) Type de type Limited Liability Companies. etc. "," Value ":", "comment": "", "parentid": 311, "ChildrenParam": null}, {"id": 321, "serviceId": 15, "name": "esdate", "type": "String", "Paramdesc": "Date d'ouverture Yyyy-mm-dd "," value ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 332," serviceId ": 15," name ":" revdate "," type ":" string "," paramdesc ":" hang date dat Yyyy-mm-dd "," valeur ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 330," serviceId ": 15," name ":" regno "," type ":" string "," paramdes ":" Enregistrement " Number "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 331," serviceId ": 15," name ":" Regorg "," type ":" String "," Paramdesc ":" Inscription Authority "," V alaue ":" "," comment ":" "," parentid ": 311," ChildrenParam ": null}, {" id ": 328," serviceID ": 15," name ":" regcap "," type ":" String "," Paramdesc ":" Regcap Unit: 10 000 Yuan "," valeur ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 329," serviceID ": 15," name ":" regcapcur "," type ":" String "," Paramdesc ":" Currency RMB, nous. ue ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 313," serviceID ": 15," name ":" opscoandform "," type ":" String "," Paramdesc ":" Scope et méthode de fonctionnement (Business) "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 315," serviceID ": 15," nom ":" ancheyear "," type ":" string "," paramdesc ":" dernière inspection annuelle yyyyyy "," valeur ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 314," serviceID ": 15," name ":" abusitem "," type ":" String "," Paramdesc ":" licence commerciale licenciée Project "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 317," ser viced ": 15," name ":" cbuuitem "," type ":" String "," Paramdesc ":" General Business " Project "," Value ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 316," serviceId ": 15," name ":" Candate "," type ":" String "," Paramdesc ":" Logout Date yyyy-mm-dd "," val ue ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 319," serviceId ": 15," name ":" Entstatus "," type ":" String "," Paramdesc ":" Statut de fonction Autre "," valeur ":" "," comment ":" "," Parentid ": 311," ChildrenParam ": null}, {" id ": 318 , "ServiceId": 15, "Name": "Dom", "Type": "String", "Paramdesc": "Address", "Value": "", "Comment": "", "Parentid": 311, "ChildrenParam": null}]}]}, "Type": "String", "String", ":" Name ":" Result "," Type " Résultat "," Value ":" Match | Not_Match | Not_Found "," Comment ":" "," ParentId ": 302," ChildrenParam ": NULL}," Status "," Value ":" "," comment ":" "," Parentid ": 302," ChildrenParam ": null}]}, {" id ": 306," serviceID ": 1 5," name ":" api_status "," type ":" jsonobject "," paramdesc ":" retour Code "," Value ":" "," comment ":" "," Parentid ": - 1," ChildrenParam ": [{" id ": 307," serviceID ": 15," Name ":" Status "," Type ":" Boolean "," Paramdesc ":" Interface Return Status "," Value ":", "comment": "," Parent ":" Interface Return Status "," Value ":" ",": "," Parent ":" Interface Return Status "," Value ":", "comment": "," Parent ":" Interface Return Status "," Value ":" ",": "," Parent " Id ": 306," ChildrenParam ": null}, {" id ": 309," serviceId ": 15," name ":" Description "," type ":" String "," Paramdes ":" Retour Status Description "," Value ":" "," comment ":" "," Parentid ": 306," ChildrenParam ": null}, {" id ": 308," serviceID ": 15," name ":" code "," type ":" strin g "," paramdesc ":" status " Code "," Value ":" "," comment ":" "," Parentid ": 306," ChildrenParam ": null}, {" id ": 310," serviceID ": 15," name ":" serial_no "," type ":" String "," Paramdesc ":" Flow Numéro "," Value ":" "," comment ":" "," Parentid ": 306," ChildrenParam ": null}]}] '; // Page API Paramètre de sortie Description $ .parsejson (JSON); console.log (données) // Nom: Paramètre Nom de l'anglais // Type: Type de paramètre // Paramdes: Paramètre Définition chinoise // Valeur: Affectation des paramètres Description // Commentaire: Paramètre Autre Description // ChildrenParam: Liste des paramètres de l'enfant console.log('----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- c = [] dataformatfn2 (data, flaghi) // statistiques Le nombre de sous-classes // chaque nœud ajoute l'attribut LEN pour compter la somme du nœud enfant et la fonction de nœud enfant DataFormatfn2 (data) {for (var i = 0; i <data.length; i ++) gens data.childrenparam.length) || 1 // Debugger // console.log (data) c = c || [] if (data.childRenparam) {for (var i = 0; i <data.childrenare.length; i ++) {b ++ data.len + = dataformatfn (data.childrenParam [i], Flati + 1, b, c [i]); data.len} else {return (data.childRenparam && data.childrenparam.length) || 0}} console.log (bbb) console.log (data) var flaghi = 0 // exécuter sur dataformatafn2 // paramhtml = jsontohtml (data, file paramhtml = ''; var nbsparr = ['', '<b> ⅰ </b>', '<b> ⅱ </b>', '<b> ⅲ </b>', '<b> ⅵ </b>', '<b> ⅴ </b>', ',' <b> ⅵ </b> ',' <b> ⅶ </b> ',' <b> ⅷ </b> ',' <b> ⅸ </b> ',' <b> ⅹ </b> '] pour (var i = 0; i <data.length; i ++) {var str2 = '' var span = 1if (i == 0 && flaghi> 0 && len> 1) {span = (10-flagi) str2 = '<td Rowspan = "' + (len) + '"> </ td>'} else {span = (10-flagi)} paramhtml + = '+ / span = sttre + '/ <td colspan = "' + span + '"> <nobr>' + nbsparr [laghi] + data [i] .name + '</br> </td> / <td>' + data [i] .type + '</td> / <td>' + data [i] .paramdes + '</td> / <td>' + data [i]. + '</td> / <td>' + data [i] .comment + '</td> / </tr>' if (data [i] .childRenparam) {paramhtml + = jSontohtml (data [i] .childrenparam, flami + 1, data [i] .len)} else {Flati}} return return paramhtml} console.log ('------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Colspan = "10"> <Nobr> Paramètre Nom de l'anglais </ NOBR> </ TH> / <TH> <NOBR> Type de paramètre </COBR> </ TH> / <TH> <NOBR> Définition chinoise </brr> </th> / <Th> <NOBR> Affectation paramètre Description </br> </th> / <Th> <Notr> Autre Instructions </ NOBR> </ TH> / </TT> / </T> / </THEAD> / <TBOBY> / '+ PARAMHTML +' / </ TBODY> / </BADE> / </div> / </dd> '$ (' # outparam dl '). html (html);} apitohtml_outparamfn (json) </cript> </body> </html>