繁体   English   中英

缩进问题

[英]Indentation issue

我想知道我对该文件的缩进是否正确,因为我得到的结果不一致(不直)。

 <html> <head> <title>Javascript for Loop</title> </head> <body> <pre> <script type = "text/javascript" > let x = 5; do { document.write("do while Looping " + x + "\n"); x++; } while (x < 10) </script> </pre> </body> </html>

结果:

在此处输入图像描述

您需要删除<pre><script>之间的文本:

 <html> <head> <title>Javascript for Loop</title> </head> <body> <pre><script type = "text/javascript" > let x = 5; do { document.write("do while Looping " + x + "\n"); x++; } while (x < 10) </script> </pre> </body> </html>

或者,更好的是,完全避免document.write

 let text = ''; let x = 5; do { text += "do while Looping " + x + "\n"; x++; } while (x < 10) document.querySelector('pre').textContent = text;
 <pre></pre>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM