js '_".html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js &#39;_&quot;</title>
</head>
<body>
<script>
    let o1 = '{&#39;username&#39;: &#39;166xxxx5257&#39;, &#39;passwordValidateInfo&#39;: &#39;密码错误!&#39;}';
    let o2 = '{&quot;username&quot;: &quot;166xxxx5257&quot;, &quot;passwordValidateInfo&quot;: &quot;密码错误!&quot;}';

    let o3 = JSON.parse(o1.replace(/&#39;/g, "\""));
    console.log("o3:", o3);
    // o3: {username: "166xxxx5257", passwordValidateInfo: "密码错误!"}
    let o4 = JSON.parse(o2.replace(/&quot;/g, "\""));
    console.log("o4:", o4);
    // o4: {username: "166xxxx5257", passwordValidateInfo: "密码错误!"}
</script>
</body>
</html>
        
        
He published 198 original articles · won praise 58 · views 80000 +

Guess you like

Origin blog.csdn.net/weixin_42193179/article/details/104022164