In VScode, Live Server keeps spinning and loading after opening the browser

Problem: When practicing the code in VScode, the live server plug-in that has been used normally suddenly appeared a problem that the web page was stuck on the loading interface. The screenshot is as follows. After a little
Please add a picture description
troubleshooting, the following reasons were ruled out:
1. Normal use, not a problem of version plug-in inadaptability
2. Modified the extension settings of Live Server, modified the port number used, but the problem cannot be solved
3. Changed the open browser, such as Firefox, Chrome, but the problem cannot be solved
Next, pass Replace the js file referenced in html, and find that the newly created js file can be opened normally without getting stuck, then the problem is that there is a problem with the code in the original js file :
HelpIndex.html:

<!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>Document</title>
    <script src="Help2.js"></script>
</head>
<body>
    <h1>js练习</h1>           
</body>
</html>

Help.js:

//concat('str1','str2','str3'...);字符串拼接
var str4='|my|';
var str5='|name|';
var str6='|is|';
var str7='|xxx|';
var str8;
str8=str4+str5+str6+str7;
console.log(str8);
//截取从2号索引开始的字符,一直到结尾
var str9=str8.substring(2);
//截取从2号索引开始,到7号索引“前”结束的字符
var str10=str8.substring(2,7);
console.log(str9);
console.log(str10);

//replace('str1','str2');将字符串str1替换为str2
var str11='aaaaabbaaaccdd';
//将a替换为e,从前到后,一次只替换一个
var str12=str11.replace('a','e');
console.log('单个替换'+str12);
//利用while将字符串里的a全部替换为e
while(str10.indexOf('a')!=-1){
    
    
  str12=str11.replace('a','e');
}
console.log('批量替换'+str12);

After investigation, it is found that there is a problem with the while loop in the code (the condition is wrong, an infinite loop occurs), comment out or correct it all, and then run the Live Server again!

Guess you like

Origin blog.csdn.net/NEXT00/article/details/128830758