分类:eggjs

eggjs

eggjs 读取数据库代码

eggjs 读取数据库代码
eggjs 读取数据库代码 效果,读取数据库前需要先连接数据库 路由配置 // 读取数据库 router.get('/api/user/:name', controller.user.info); controller 代码 // app/controller/use...

yekong 2年前 (2022-02-03) 1028℃ 0喜欢

eggjs 连接数据库配置

eggjs 连接数据库配置
添加配置 config/plugin.js 'use strict'; /** @type Egg.EggPlugin */ // module.exports = { // // had enabled by egg // mysql: { // enabl...

yekong 2年前 (2022-02-03) 1253℃ 1喜欢

eggjs 引入axios组件

eggjs 引入axios组件
安装依赖 npm i axios --save 引入 const axios = require('axios'); 使用实例eggjs 使用高德地图查询天气 ...

yekong 2年前 (2022-02-02) 1060℃ 0喜欢

eggjs post请求时报invalid csrf token

eggjs post请求时报invalid csrf token
invalid csrf token 如果是开发模式的话,可以暂时关闭,关闭方法 找到config/config.default.js 添加csrf配置,关闭csrf // csrf config.security = { csrf: { enabl...

yekong 2年前 (2022-01-21) 1792℃ 0喜欢

eggjs get 请求严格模式传参

eggjs get 请求严格模式传参
严格传参模式 除了严格模式还有普通的传参模式 控制器 async strictGet() { const { ctx } = this; ctx.body = { code: 200, data: ctx.params.name, ...

yekong 2年前 (2022-01-21) 853℃ 0喜欢

eggjs get方式获取参数

eggjs get方式获取参数
普通传参模式 除了常规模式还有严格的传参模式 控制器 async test() { const { ctx } = this; ctx.body = { code: 200, data: ctx.query, }; ...

yekong 2年前 (2022-01-21) 1118℃ 1喜欢

egg.js 初始化安装

egg.js 初始化安装
初始化项目 mkdir egg-example && cd egg-example npm init egg --type=simple npm i 启动项目 npm run dev open http://localhost:7001 ...

yekong 2年前 (2022-01-19) 780℃ 0喜欢