JavaScript 根本不会 运行
JavaScript will not run at all
我有这个模板作为我的 sinatra layout.erb
<!DOCTYPE html>
<html>
<head>
<title>Invoicer</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/static/css/font-awesome.min.css">
</head>
<body>
<nav class="navbar navbar-default">
...
</nav>
<div class="container">
<%= yield %>
</div>
<%#<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>%>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="/static/js/bootstrap.min.js"/>
<script src="/static/js/jobs/new.js" />
</body>
</html>
还有这个小 javascript 电话
console.log("running")
$('#datepicker').datepicker()
服务器收到对 js 文件的 200 次调用,但没有任何内容会打印到控制台或执行。
始终使用 <script></script>
.
<script src="..." />
不是有效标签。当 HTML 被解析时,它认为 <script src="/static/js/jobs/new.js" />
在 <script src="/static/js/bootstrap.min.js"/>
标签的 body 中,像这样:
...
<script src="/static/js/bootstrap.min.js">
<script src="/static/js/jobs/new.js">
...
Tag omission
None, both the starting and ending tag are mandatory.
我有这个模板作为我的 sinatra layout.erb
<!DOCTYPE html>
<html>
<head>
<title>Invoicer</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/static/css/font-awesome.min.css">
</head>
<body>
<nav class="navbar navbar-default">
...
</nav>
<div class="container">
<%= yield %>
</div>
<%#<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>%>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="/static/js/bootstrap.min.js"/>
<script src="/static/js/jobs/new.js" />
</body>
</html>
还有这个小 javascript 电话
console.log("running")
$('#datepicker').datepicker()
服务器收到对 js 文件的 200 次调用,但没有任何内容会打印到控制台或执行。
始终使用 <script></script>
.
<script src="..." />
不是有效标签。当 HTML 被解析时,它认为 <script src="/static/js/jobs/new.js" />
在 <script src="/static/js/bootstrap.min.js"/>
标签的 body 中,像这样:
...
<script src="/static/js/bootstrap.min.js">
<script src="/static/js/jobs/new.js">
...
Tag omission
None, both the starting and ending tag are mandatory.