求解Jade 如何获取koa2 中的变量,ctx.state 对应 express 里的 res.locals
//app.js
res.locals.success = 'xxxxxxxx'
//jade
-if(locals.success)
div#alt_sucess.alert.alert-success !{locals.success}
-if(locals.error)
div#alt_warning.alert.alert-warning error
2 回复
// app.js
ctx.state.success = 'xxxxxxxx';
/*
ctx.status = {
success: 'xxxxxxxx'
};
*/
// jade
-if(success)
div#alt_sucess.alert.alert-success !{success}
-if(error)
div#alt_warning.alert.alert-warning error
@SinalVee 十分感谢,可行。
//app.js
ctx.state= {
session: this.session,
error: '用户名已存在'
}
// jade
-if(success)
div#alt_sucess.alert.alert-success !{success}
-if(error)
div#alt_warning.alert.alert-warning !{error}