js字符串前加空格
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>字符串前加空格</title> </head> <body> <h1></h1> </body> </html> <script> const str = '\xa0\xa0\xa0\xa0' + '测试' const h1 = document.getElementsByTagName('h1')[0] h1.innerText = str </script>