【发布时间】:2017-08-14 17:53:07
【问题描述】:
我设置了以下路线:
router.get('/', function(req, res) {
res.render('index', {});
});
router.post('/application', function(req, res) {
res.render('application', {twitchLink : req.query.twitchLink});
});
我已经正确设置了两个视图。
这是我在“索引”视图中看到的:
<form class="form-horizontal" action="/application", method="post", role="form">
<input type="url" name="twitchLink" required>
<button class="btn btn-success">Submit</button>
</form>
提交此表单确实会将我带到应用程序视图。
<script>var twitchLink = <%- JSON.stringify(twitchLink) %></script>
<script>console.log(twitchLink)</script>
这应该注销我提交的链接,对吧? 但是,我得到了这两行:
Uncaught SyntaxError: Unexpected end of input
Uncaught ReferenceError: twitchLink is not defined
【问题讨论】:
-
你找到解决办法了吗?