.tpl模板(模板文档链接 && 语法链接) vscode高亮,参考链接https://blog.youkuaiyun.com/u013488308/article/details/79509216
router 与 controller对应关系 再到页面的渲染


一个controller可以指定多个渲染的页面

添加业务逻辑到 app/service(有内置HttpClient)
vscode 调试 具体戳这里
- package.json文件添加 debug命令
"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "open": "node config/open-server.js", "dev": "egg-bin dev", "debug": "egg-bin debug" },
然后进入 vscode 调试,会自动生成.vscode/launch.json 参照链接戳这里
-
egg引用静态资源 public文件内容 了解戳
mac debug启动失败
-
提示
无法连接到运行中的进程,将在10000毫秒后超时 - (原因:无法附加到此目标,其可能附加了 Chrome DevTools: file:///Users/teresa/Downloads/CodeDownload/Gitee/egg-example/node_modules/egg-bin/lib/start-cluster)
或者his socket has been ended by other party 参考链接
其实我按照链接中到方法,没有解决问题,选择用了webstorm 进行debug,参考链接戳
单元测试
- power-assert
- Mocha
- Egg.js单元测试
- egg-mock 提供bootstrap文件可以便捷拿到常用实例(app、ctx等)