微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

未捕获的SyntaxError:Bootstrap.esm.min.js:6

如何解决未捕获的SyntaxError:Bootstrap.esm.min.js:6

一个.PHP文件,我想在上面使用jquery,在我对其进行更多操作之前,我想先尝试一下它是否适用于该页面。当我单击提交时,javascript完全不在页面上执行任何操作,以下是控制台上的错误以及代码的性质。

html页面

 <div class="col-8">

        <form  action="bar.PHP " method="post">
   get fields:</br>

 <input type="text" name="goods"id="barid"><br>
 <br>

  <input type="submit" value=" click" name="submit">
</form>




   </div>
 </br>
 <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
  </body>


</html>

bar.PHP

<?PHP


if(isset($_POST["click"])){
   
    $s = $_POST['goods'];

    $fields= test_input($s);

}

function test_input($name) {
    $data = trim($name);
    $data = stripslashes($name);
    $data = htmlspecialchars($name);
    return $name;
  }




echo "<script>
 $(document).ready(function(){
     

         alert ('$goods');
     });

 </script>"; 

var_dump($goods); //this works quite okay

?>

这是我在控制台上出现的错误

未捕获的SyntaxError:Bootstrap.esm.min.js:6无法在模块外部使用import语句

解决方法

好吧,经过大量研究,我发现了这一点;我将jquery链接从我的页脚文件移动到了我的头文件,下面是该文件的最终产品..并且开始工作。

 <head>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.esm.min.js" integrity="sha384-sKZy8g2KJhBTFCD6cIg8d4EifJxaa8c/iYIERdeKorHWhAgZgQOfqOKMe3xBqye1" crossorigin="anonymous"></script>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">

    <link rel="stylesheet" type="text/css" href="css/paperpdf.css">
    <title>$title</title>
  </head>









 </div>
 </br>

    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
  </body>


</html>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。