pre 标签和 code 标签联合应用的成果 let data = JSON.stringify({name: 'tim', age: 23, grade: 3}, null, 2); <pre> <code id="json">{data}</code> </pre> // 结果显示为这样, { "name": "tim", "age": 23, "grade": 3 }