当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 得到后台数据,按照名称,循环赋值给表单

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

2019年08月01日  | 移动技术网IT编程  | 我要评论
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>接口获取值后赋值</title>
</head>
<body>
    <script>
        let response = { // 后台传递的json
            name: 'shui',
            age: 18,
            sex: 'boy'
        }
        let form = {} // 前端表单
        object.keys(response).foreach(key => form[key] = response[key]) // 按照名称一一赋值
        console.log(form)
    </script>
</body>
</html>

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网