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.添加路由

egg 项目实战(二)初始Egg.js中的路由

相关文章:

  • 2021-10-30
  • 2021-05-19
  • 2022-02-09
  • 2021-11-24
  • 2022-12-23
  • 2020-02-22
  • 2021-08-16
猜你喜欢
  • 2021-11-23
  • 2021-08-11
  • 2021-08-11
  • 2021-10-11
  • 2021-11-27
  • 2021-05-29
  • 2021-08-30
相关资源
相似解决方案