<!DOCTYPE html> <html> <head lang="en"> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.js"></script> </head> <body> <!-- 只能用双引号的情况下拼接 --> <script> let a = "{\"state\":\"no\"}", b = "{\"code\":\"" + 1 + "\",\"message\":\"" + 2 + "\",\"requestid\":\"" + 3 + "\",\"SubsId\":\"" + 4 + "\",\"SecretNo\":\"" + 5 + "\"}"; console.log(a); console.log(b); </script> </body> </html>