上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 142 下一页
摘要: Egg.js 中 session 的使用 设置 session this.ctx.session.username = '张三'; 获取 session let username = this.ctx.session.username; Session的默认配置 // Session的默认配置 ex 阅读全文
posted @ 2020-03-12 12:00 每天都要进步一点点 阅读(3435) 评论(0) 推荐(1)
摘要: cookie: 1、可以实现 同一个浏览器访问同一个域的时候 不同页面之间的数据共享 2、实现数据的持久化 (关闭浏览器重新打开以后数据还存在) 第一个参数:cookies的名称 第二个参数:cookies的值 第三个参数:配置 设置cookie this.ctx.cookies.set('user 阅读全文
posted @ 2020-03-11 12:00 每天都要进步一点点 阅读(2889) 评论(0) 推荐(0)
摘要: 网址: http://eggjs.org/zh-cn/core/security.html 方式一: 在 controller 中通过参数传入模板 /** * 方式一:在 controller 中通过参数传入模板 * this.ctx.csrf 用户访问这个页面的时候生成一个密钥 */ await 阅读全文
posted @ 2020-03-10 12:00 每天都要进步一点点 阅读(2799) 评论(0) 推荐(0)
摘要: 中间件:匹配路由前、匹配路由完成做的一系列操作。Egg是基于Koa实现的,所有Egg的中间件形式和Koa的中间件形式是一样的,都是基于洋葱模型。 Koa中的中间件:https://eggjs.org/zh-cn/intro/egg-and-koa.html#middleware Egg中的中间件:h 阅读全文
posted @ 2020-03-09 12:00 每天都要进步一点点 阅读(1507) 评论(0) 推荐(0)
摘要: 1.创建 helper 扩展方法 app/extend/helper.js /** * app/extend/helper.js * 扩展里面引入第三方模块 * https://www.npmjs.com/package/silly-datetime * 1、yarn add silly-datet 阅读全文
posted @ 2020-03-08 12:00 每天都要进步一点点 阅读(1476) 评论(0) 推荐(0)
摘要: 1.抓取的接口 /** * 抓取的接口 * 新闻列表接口:http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1 * 新闻详情接口:http://www.phonegap100.com/appapi.php?a=ge 阅读全文
posted @ 2020-03-07 12:00 每天都要进步一点点 阅读(1273) 评论(0) 推荐(0)
摘要: 1、安装mysql npm i egg-mysql -S 2、在config/plugin.js里声明改插件 exports.mysql = { enable: true, package: 'egg-mysql', }; 3、在config/config.default.js里配置 config. 阅读全文
posted @ 2020-03-06 12:00 每天都要进步一点点 阅读(5378) 评论(0) 推荐(1)
摘要: 1.开发文章首页接口 app/service/article.js const Service = require('egg').Service; class ArticleService extends Service { async lists() { const { app } = this; 阅读全文
posted @ 2020-03-05 12:00 每天都要进步一点点 阅读(1243) 评论(0) 推荐(0)
摘要: 1.创建 service 文件 app/service/article.js const Service = require('egg').Service; class ArticleService extends Service { async create(params) { const { a 阅读全文
posted @ 2020-03-04 12:00 每天都要进步一点点 阅读(909) 评论(0) 推荐(0)
摘要: 1.创建 mysql 表结构 create database egg_article; use egg_article; create table article( id int(10) not null auto_increment, img text default null comment ' 阅读全文
posted @ 2020-03-03 12:00 每天都要进步一点点 阅读(2821) 评论(0) 推荐(0)
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 142 下一页