热门关键字:
jquery > jquery教程 > html5 > 得到后台数据,按照名称,循环赋值给表单

得到后台数据,按照名称,循环赋值给表单

359
作者:管理员
发布时间:2020/3/17 10:59:48
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=1051

  <!DOCTYPEhtml>

  <htmllang="en">

  <head>

  <metacharset="UTF-8">

  <metaname="viewport"content="width=device-width,initial-scale=1.0">

  <metahttp-equiv="X-UA-Compatible"content="ie=edge">

  <title>接口获取值后赋值</title>

  </head>

  <body>

  <script>

  letresponse={//后台传递的json

  name:'shui',

  age:18,

  sex:'boy'

  }

  letform={}//前端表单

  Object.keys(response).forEach(key=>form[key]=response[key])//按照名称一一赋值

  console.log(form)

  </script>

  </body>

  </html>





如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:html
友荐云推荐