1.创建 product 控制器
app/controller/product.js
const Controller = require('egg').Controller; class ProductController extends Controller { async index() { /** * ctx 主要用来存储用户请求的信息 * 每次请求时都会实例化 */ const { ctx } = this; ctx.body = 'product'; } } module.exports = ProductController;
2.添加路由