题解 | #接口#
接口
https://www.nowcoder.com/practice/8f91b606181746558e8a398e513d1078
{"html":"<!DOCTYPE html>\r\n<html>\r\n <head>\r\n <meta charset=utf-8>\r\n </head>\r\n <body>\r\n \t\r\n <script type=\"text/javascript\">\r\n let data = [\r\n {name: 'nowcoder1'},\r\n {name: 'nowcoder2'}\r\n ]\r\n \r\n const _api = string => {\r\n // 补全代码\r\n let arr = string.split('?');\r\n let method = arr[0];\r\n if(method==='get'){\r\n return data\r\n }\r\n let fromTo = arr[1].split('&').map(item=>item.split('=')[1]);\r\n data = data.map(item=>{\r\n if(item.name===fromTo[0]){\r\n item.name = fromTo[1]\r\n }\r\n return item\r\n })\r\n\r\n }\r\n </script>\r\n </body>\r\n</html>","css":"/* html, body {\\n\\twidth: 100%;\\n\\theight: 100%;\\n\\tmargin: 0;\\n\\tpadding: 0;\\n} */","js":"// 请在这里输入代码"}