1.创建service文件 app/service/product.js const Service = require('egg').Service; class ProductService extends Service { async index ...
.GET 方法 商品详情 async detail const ctx this console.log ctx.query ctx.body id ctx.query.id async detail const ctx this console.log ctx.params ctx.body id ctx.params.id router.get product detail , contro ...
2020-02-29 12:00 0 1521 推荐指数:
1.创建service文件 app/service/product.js const Service = require('egg').Service; class ProductService extends Service { async index ...
1.安装 ejs yarn add egg-view-ejs 2.修改配置 config/plugin.js 'use strict'; exports.ejs = { enable: true, package: 'egg ...
1.创建 mysql 表结构 create database egg_article; use egg_article; create table article( id int(10) not null auto_increment, img text default ...
1.开发文章首页接口 app/service/article.js const Service = require('egg').Service; class ArticleService extends Service { async lists() { const ...
1.创建 service 文件 app/service/article.js const Service = require('egg').Service; class ArticleService extends Service { async create(params ...
之前已经简单的使用egg-init初始化项目,并创建控制器controller和服务service 在实际项目中, service主要负责数据的请求,并处理(http请求) controll主要负责获取service中得到的最终数据,并渲染给模板view view主要负责模板 ...
egg.js in action fullstack https://github.com/eggjs/egg/ cli config router service midlewares HTTP CURD async / await template ...
一、Egg简介绍 Express和Koa缺少约定,缺少规范,Eggjs对MVA进行约定规范,为企业框架而生。 特性: 基于Egg定制上层框架。 高度可扩展插件机制。 内置多进程管理。对比Nodejs。 框架稳定,测试覆盖率高。 渐进式开发。模块——》插件——》框架的演变。 Egg ...