if (result.success) {
                        var obj = JSON.parse(result.data);
                        var sltObj = document.getElementById("selUser"); //获取select对象
                        for (var i = 0; i < obj.length; i++) {
                            var optionObj = document.createElement("option"); //创建option对象
                            optionObj.value = Object.keys(obj[i]); //获取属性名称
                            optionObj.innerHTML = obj[i][Object.keys(obj[i])];//获取属性名称的值
                            sltObj.appendChild(optionObj);  //添加到select
                        }
                        console.log(result.data);
                    }
                    else {
                        layer.msg(result.data);
               var sltObj = document.getElementById("selUser"); //获取select对象
               sltObj.options.length = 0;
                    }

 

              for(variable  in test001){   //variable 为属性名
                    console.log(variable)   //name age
                }

 

相关文章:

  • 2021-06-22
  • 2021-09-22
  • 2021-12-28
  • 2021-06-15
猜你喜欢
  • 2022-12-23
  • 2021-12-22
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案