一、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 ...