
egg
当代词圣李白
这个作者很懒,什么都没留下…
展开
-
egg Cannot find module ‘diagnostics_channel‘
出现 Cannot find module 'diagnostics_channel'原创 2022-10-30 12:05:16 · 3434 阅读 · 1 评论 -
egg-sequelize update +1
// service/xx.jsconst { literal } = require("sequelize");await app.model.xx.update( { total: literal("total + 1"), }, { where: { id:1, }, });原创 2021-07-27 22:32:55 · 751 阅读 · 0 评论 -
egg 如何设置跨域,并且携带cookie
首先安装跨域的插件并配置开启在本地开发配中配置域名在登录接口中设置cookie前端请求设置withCredentials项目参考地址下载了你应该跑不了,可以参考一下原创 2021-05-30 11:26:29 · 925 阅读 · 0 评论 -
EGG 跨域 when the request‘s credentials mode is ‘include‘. The credentials mode of requests initiated
(一) 当前端配置withCredentials=true时, 后端配置Access-Control-Allow-Origin不能为*, 必须是相应地址(二) 当配置withCredentials=true时, 后端需配置Access-Control-Allow-Credentials(三) 当前端配置请求头时, 后端需要配置Access-Control-Allow-Headers为对应的请求头集合...原创 2020-12-29 22:35:36 · 4563 阅读 · 0 评论 -
egg 自定义环境
自定义环境有两种方法第一种 设置windows 系统变量第二种在 package.json 添加 cross-env 模块原创 2020-12-23 21:31:38 · 323 阅读 · 0 评论 -
egg 文件中转下载
后台代码:controller: const fs = require('fs'); const path = require('path'); var request = require('request'); async downLoad() { const { ctx } = this; let url = ctx.query.url || null; function downloadFile(url, filename, callback) { v原创 2020-06-03 14:16:12 · 1159 阅读 · 0 评论 -
egg 返回图片,前端下载图片
node 代码: async getFile() { const { ctx } = this; ctx.set('content-type','image/jpeg') ctx.body = fs.createReadStream('static/1.jpg'); }路由 router.get('/getFile', controller.home.getFile);前端代码 const eleLink = document.createElement('a')原创 2020-05-31 18:21:03 · 2340 阅读 · 0 评论 -
EGG 问题记录
vue + egg 页面报错,css 引入不了没有设置静态文件路径,默认是 app/public/ 下,egg 框架页面路径是 app/view/,所以我们把vue打包生成后的文件放到 app/view/ ,然后在app/config/config.default.js 添加如下代码:config.static = {prefix: “/”,dir: [path.join(appInfo...原创 2019-07-08 12:51:23 · 263 阅读 · 0 评论