您好,登錄后才能下訂單哦!
一 取值 post 和get取值
1)
GET /test?name=fred&tel=0926xxx572
app.get('/test', function(req, res) {
console.log(req.query.name);
console.log(req.query.tel);
});
2)POST
<form action='/test' method='post'>
<input type='text' name='name' value='fred'>
<input type='text' name='tel' value='0926xxx572'>
<input type='submit' value='Submit'>
</form>
app.post('/test', function(req, res) {
console.log(req.query.id);
console.log(req.body.name);
console.log(req.body.tel);
});
3) HTTP Routing :
GET /hello/fred/0926xxx572
app.get('/hello/:name/:tel', function(req, res) {
console.log(req.params.name);
console.log(req.params.tel);
});
參考:
https://cnodejs.org/topic/50a333d7637ffa4155c62ddb
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。