在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ladjs/koa-better-flash开源软件地址:https://github.com/ladjs/koa-better-flash开源编程语言:JavaScript 100.0%开源软件介绍:koa-better-flash
Table of ContentsInstallnpm: npm install koa-better-flash yarn: yarn add koa-better-flash Usageconst Koa = require('koa');
const Router = require('koa-router');
const session = require('koa-generic-session');
const flash = require('koa-better-flash');
const app = new Koa();
const router = new Router();
router.post('/', (ctx, next) => {
// you can also pass an array of messages:
// ctx.flash('info', [ 'hi', 'hello', 'good morning' ]);
ctx.flash('info', 'hello world');
ctx.status = 200;
});
router.get('/', ctx => {
// to get all messages by type simply call `ctx.flash()`
ctx.body = ctx.flash('info');
// outputs: [ 'hello world ']
});
app.keys = [ 'keys' ];
app.use(session());
app.use(flash());
app.use(router.routes());
app.listen(); Contributors
License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论