你的位置:首页 > Java教程

[Java教程]koa

const Koa = require('koa');const route = require('koa-route');const app = new Koa();const about = ctx => { ctx.response.body = 'Hello World111';};const main = ctx => { ctx.response.body = 'Hello World222';};const details = (ctx,id) => { ctx.response.body = id+'Hello World222';};app.use(route.get('/', main));app.use(route.get('/about', about));app.use(route.get('/details/:id', details)); //参数一定要写在斜杠冒号后面// app.use(main);app.listen(3000);