得到后台数据,按照名称,循环赋值给表单
程序员文章站
2022-03-14 13:45:45
接口获取值后赋值 ......
<!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>
上一篇: 大快朵颐正当时
下一篇: python 运算符