nuxt.js 路由

创建路由 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());
}

 

 

 

 

你可能感兴趣的:(nuxt)