ctx.request.body:
需要安裝koa-bodyparsernpm插件,獲取post請(qǐng)求參數(shù);
ctx.params:
獲取動(dòng)態(tài)路徑參數(shù);
router.get('/package/:aid/:cid',async (ctx)=>{
//獲取動(dòng)態(tài)路由的傳值
console.log(ctx.params); //{ aid: '123', cid: '456' }
ctx.body="詳情";
})
ctx.request.query:
獲取解析的查詢字符串, 當(dāng)沒有查詢字符串時(shí),返回一個(gè)空對(duì)象
// url?color=blue&size=small
{
color: 'blue',
size: 'small'
}