未捕获的语法错误:Bootstrap.esm.min.js:6
Posted
技术标签:
【中文标题】未捕获的语法错误:Bootstrap.esm.min.js:6【英文标题】:Uncaught SyntaxError: Bootstrap.esm.min.js:6 【发布时间】:2021-01-03 14:01:34 【问题描述】:我想在一个 .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
?>
这是我在控制台上遇到的错误:
Uncaught SyntaxError: Bootstrap.esm.min.js:6 Cannot use import statement outside a module
【问题讨论】:
【参考方案1】:好的,经过大量研究,我想通了;我将 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>
【讨论】:
以上是关于未捕获的语法错误:Bootstrap.esm.min.js:6的主要内容,如果未能解决你的问题,请参考以下文章
带有消息“SQLSTATE [42000]”的未捕获异常“PDOException”:语法错误或访问冲突:
PHP 致命错误:未捕获的 PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误