gpt4 book ai didi

javascript - "_ is not defined"HTML 文件中下划线错误

转载 作者:太空宇宙 更新时间:2023-11-04 02:40:01 25 4
gpt4 key购买 nike

这个来自node.js项目的html文件最初是jedireza来自Drywall.js项目的jade注册文件。它在 GitHub 上的位置是: https://github.com/jedireza/drywall/blob/master/public/views/signup/index.js

通过jade的内部转换器转换它并使用ejs模板引擎渲染它后,出现以下错误:

_ is not defined
at eval (eval at <anonymous> (/var/lib/stickshift/51cee2af5973cad1b20002b5/app-root/data/543117/node_modules/ejs/lib/ejs.js:236:14))
at eval (eval at <anonymous> (/var/lib/stickshift/51cee2af5973cad1b20002b5/app-root/data/543117/node_modules/ejs/lib/ejs.js:236:14))
at exports.compile (/var/lib/stickshift/51cee2af5973cad1b20002b5/app-root/data/543117/node_modules/ejs/lib/ejs.js:249:15)
at Object.exports.render (/var/lib/stickshift/51cee2af5973cad1b20002b5/app-root/data/543117/node_modules/ejs/lib/ejs.js:287:13)

HTML文件如下:

<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/vendor/bootstrap/css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/layouts/utility.css">
<link rel="stylesheet" href="/layouts/default.css">
<script src="/vendor/jquery/jquery-1.9.1.min.js"></script>
<script src="/vendor/underscore/underscore-min.js"></script>
<script src="/vendor/backbone/backbone-min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/layouts/utility.js"></script>
<script src="/views/signup/index.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js"></script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a data-toggle="collapse" data-target=".nav-collapse" class="btn btn-navbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><a href="/" class="brand"><img src="/media/logo-black.png" width="150"></a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/signup/">Sign Up</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>
<ul class="nav pull-right">
<li><a href="/login/"><i class="icon-user"></i> Login</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="page">
<div class="container">
<div class="page-header">
<h1>Sign Up</h1>
</div>
<div id="signup"></div>
<script type="text/template" id="tmpl-signup"><form class="form-horizontal"><div class="alerts">
***<% _.each(errors, function(err)*** { %><div class="alert alert-error"><button type="button" data-dismiss="alert" class="close">&times;</button><%= err %></div><% }); %>
</div><div class="control-group &lt;%= errfor.username ? &quot;error&quot; : &quot;&quot; %&gt;"><label class="control-label">Pick a Username:</label><div class="controls"><input type="text" name="username" value="<%= username %>"><span class="help-inline"><%= errfor.username %></span></div></div><div class="control-group &lt;%= errfor.email ? &quot;error&quot; : &quot;&quot; %&gt;"><label class="control-label">Enter Your Email:</label><div class="controls"><input type="text" name="email" value="<%= email %>"><span class="help-inline"><%= errfor.email %></span></div></div><div class="control-group &lt;%= errfor.password ? &quot;error&quot; : &quot;&quot; %&gt;"><label class="control-label">Create a Password:</label><div class="controls"><input type="password" name="password" value="<%= password %>"><span class="help-inline"><%= errfor.password %></span></div></div><div class="form-actions"><button type="button" class="btn btn-primary btn-signup">Create My Account</button></div></form></script>
</div>
</div>
<div class="footer">
<div class="container">
<div class="inner">
<span class="copyright pull-right">&#169; </span>
<ul class="links">
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/signup/">Sign Up</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="ajax-spinner"><img src="/media/ajax-pulse.gif"></div>

</body>
</html>

粗斜体行是触发错误的行。 underscore.js 文件已包含在内。感谢您的建议和帮助!

最佳答案

http://underscorejs.org 添加下划线.js .

这确实是js错误。

关于javascript - "_ is not defined"HTML 文件中下划线错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17458479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com