路由 / 传值 / 模板引擎
1、Egg 路由配置
https://eggjs.org/zh-cn/basics/router.html
2、获取 Get 传值以及动态路由的值
https://eggjs.org/zh-cn/basics/controller.html
3、egg-view-ejs 的使用
https://github.com/eggjs/egg-view-ejs
其他:https://eggjs.org/zh-cn/core/view.html
1. 安装
npm i egg-view-ejs --save
2. 找到 {app_root}/config/plugin.js
exports.ejs = {
enable: true,
package: 'egg-view-ejs',
};
3. 找到 {app_root}/config/config.default.js
module.exports = appInfo => {
const config = exports = {};
// use for cookie sign key, should change to your own and keep security
config.keys = appInfo.name + '_1532498393023_7447';
// add your config here
config.middleware = [];
//配置 ejs 模板引擎
config.view = {
mapping: {
'.html': 'ejs',
}
};
return config;
};
Last updated
Was this helpful?