使用 Jade 和 Node.js 传递动态 URL
Passing dynamic URL using Jade and Node.js
我是 Node.js 的新手,遇到了一些小问题。
当用户在文本框中输入 Java 并单击提交按钮时,它应该转到 http://localhost:3000/search/Java
我们在翡翠怎么做?
帮助高度赞赏。提前致谢
extends layout
block content
.container
p(style='white-space:pre;') You are currently logged in as #{user.username}
br
a(href="/logout") Logout
br
form(role='form', action="/search",method="get", style='max-width: 300px;')
.form-group
input.form-control(type='text', name="search", placeholder='enter something')
button.btn.btn-default(type='submit') Submit
router.get('/search/:id', function(req, res){
Object.find({searchType: req.params.id},function (err, docs){
res.render('search', {search: docs, user : req.user , title : 'Search'});
});
})
你在找这个吗?
response.writeHead(302, {
'Location': 'YourNewURL'
//add other headers here...
});
response.end();
通过包含 javascript
解决
script.
var something = function() {
window.location.href = "search/" +
document.getElementById('search').value;
}
我是 Node.js 的新手,遇到了一些小问题。
当用户在文本框中输入 Java 并单击提交按钮时,它应该转到 http://localhost:3000/search/Java
我们在翡翠怎么做?
帮助高度赞赏。提前致谢
extends layout
block content
.container
p(style='white-space:pre;') You are currently logged in as #{user.username}
br
a(href="/logout") Logout
br
form(role='form', action="/search",method="get", style='max-width: 300px;')
.form-group
input.form-control(type='text', name="search", placeholder='enter something')
button.btn.btn-default(type='submit') Submit
router.get('/search/:id', function(req, res){
Object.find({searchType: req.params.id},function (err, docs){
res.render('search', {search: docs, user : req.user , title : 'Search'});
});
})
你在找这个吗?
response.writeHead(302, {
'Location': 'YourNewURL'
//add other headers here...
});
response.end();
通过包含 javascript
解决script.
var something = function() {
window.location.href = "search/" +
document.getElementById('search').value;
}