创建路由 server/interface/city.js
import Router from "koa-router"
//路由
const router = new Router({
prefix: "/city"
})
router.get("/list", async (ctx) => {
ctx.body = ['北京', "天津"]
});
export default router
引入路由 server/index.js
import cityInterface from './interface/city.js'
async function start () {
app.use(cityInterface.routes()).use(cityInterface.allowedMethods());
}

被折叠的 条评论
为什么被折叠?



