<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>js '_"</title> </head> <body> <script> let o1 = '{'username': '166xxxx5257', 'passwordValidateInfo': '密码错误!'}'; let o2 = '{"username": "166xxxx5257", "passwordValidateInfo": "密码错误!"}'; let o3 = JSON.parse(o1.replace(/'/g, "\"")); console.log("o3:", o3); // o3: {username: "166xxxx5257", passwordValidateInfo: "密码错误!"} let o4 = JSON.parse(o2.replace(/"/g, "\"")); console.log("o4:", o4); // o4: {username: "166xxxx5257", passwordValidateInfo: "密码错误!"} </script> </body> </html>
js '_".html
Guess you like
Origin blog.csdn.net/weixin_42193179/article/details/104022164
Ranking