node+koa2獲取請求參數

1.get方式:koa

http://localhost:3000/?user=000001&body=0002&age=26async

const router = require('koa-router')()post

router.get('/',async (ctx, next) => {
console.log('接受到的參數爲:'+ctx.request.query.user);
await ctx.render('index', {
title: 'Hello Koa 22222222222222222!'
})
})ui

2.post方式:google

ctx.request.body.userspa

 3.重定向:router

ctx.redirect('http://google.com');get

相關文章
相關標籤/搜索