代码如下,无法正常进入路由,求指点。
index.js: import Koa from 'koa' import router from './middleware/router' const app = new Koa() app.use(router);
router.js: import Router from 'koa-router' const router = new Router() export default function (ctx, next) { console.log('ctx:', ctx); console.log('next:', next); router.get('/', function (ctx, next) { console.log('我是首页'); ctx.body('我是首页'); });
router.get('/next', function (ctx, next) {
console.log('我是next');
ctx.body('我是next');
});
router.routes();
router.allowedMethods();
return router;
}
回复 (5)
参与回复
登录后即可参与回复。登录