得到后台数据,按照名称,循环赋值给表单
程序员文章站
2022-06-24 09:17:53
接口获取值后赋值 ......
<!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>