一、egg-mysql 的安装配置 1、在 egg 项目中安装 egg-mysql 2、在 {app_root}/config/plugin.js 中启用 egg-mysql 插件 ...
.创建 mysql 表结构 create database egg article use egg article create table article id int not null auto increment, img text default null comment 缩略图 , title varchar default null comment 文章标题 , summary va ...
2020-03-03 12:00 0 2075 推荐指数:
一、egg-mysql 的安装配置 1、在 egg 项目中安装 egg-mysql 2、在 {app_root}/config/plugin.js 中启用 egg-mysql 插件 ...
1.GET 方法 // 商品详情 async detail() { const { ctx } = this; console.log(ctx.query); ctx.body = ...
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.通过 egg-init 初始化一个项目: egg-init --type=simple --dir=sequelize-projectcd sequelize-projectnpm i 2.安装并配置 egg-sequelize 插件(它会辅助我们将定义好的 Model 对象加载到 app ...
1.egg项目中安装 egg-sequelize和mysql2 2.在plugin.js 中插入以下代码 3.在config.default.js中填写数据库链接配置信息。 4.配置router,模型添加字段同步数据库 ...
一、Egg.js 中使用第三方插件 Egg.js 是基于 nodejs,所以可以使用 nodejs 的所有模块,使用方式就是在用到的地方引入对应模块,然后按照文档使用。 二、Egg.js 插件 ...
1.开发文章首页接口 app/service/article.js const Service = require('egg').Service; class ArticleService extends Service { async lists() { const ...