我正在开发一个非常简单的 Vapor 应用程序。我目前正在研究其中一种观点:
#extend("base")
#export("body") {
<form>
<div class="row">
<div class="six columns">
<label for="exampleEmailInput">Acronym</label>
<input class="u-full-width" type="email" id="short">
</div>
<div class="six columns">
<label for="exampleRecipientInput">Long form</label>
<input class="u-full-width" type="email" id="long">
</div>
</div>
</form>
<div class="row">
<div class="five columns"></div>
<div class="two columns">
<a class="button button-primary" id="submit" href="/acronym/all">Save Acronym</a>
</div>
<div class="five columns"></div>
</div>
<script>
function setHref() {
var short = $("#short").val();
}
</script>
}
这段代码一直有效,直到我将short
变量添加到setHref
函数中。然后我得到一个解析错误:
Uncaught Error: ParseError.tagTemplateNotFound("short\").val"). Use middleware to catch this error and provide a better response. Otherwise, a 500 error page will be returned in the production environment.
为什么会这样?