<!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