<!DOCTYPE html> <html lang="zh-CN"> <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>使用js</title> <link rel="stylesheet" href="./css/app.css"> </head> <body> <div class="container"> <div class="menu"> <div class="import-box"> 加载中...... </div> </div> <div class="context"> <span>主页内容区</span> </div> </div> <script> fetch("./Import.html") .then(response=> response.text()) .then(text=> document.getElementsByClassName("import-box")[0].innerHTML = text); </script> </body> </html>