Based on project development node + koa2
At the beginning of the project, make sure the computer is installed node v10.16.0
Taobao accelerated mirroring configuration npm
# 查看默认的 registry 地址
npm config -g get registry
输出:https://registry.npmjs.org/
# 设置 npm 淘宝镜像
npm config -g set registry https://registry.npm.taobao.org
1, mounted on koa2
npm install koa --save
2, install Project Builder koa2
npm install koa-generator -g
3. Create a project
koa2 [项目名称]
4, mounted reliance
cd [项目名称]
npm install
5, start the service
npm start
axios
https://blog.csdn.net/qq_30669833/article/details/81701588
koa2 set ejs as a template engine, but the final document is .html
At work in many cases we need to use the syntax ejs template engine, but we hope that the page or html file:
configuration in order koa2 of a code can be resolved;
const Koa = require('koa');
const app = new Koa();
...
const ejs = require('ejs');
...
app.use(views(__dirname + '/views', {
map : {html:'ejs'}
}));
That's it, you can use ejs syntax <%%> in the html file.
Some plug-ins
https://www.jianshu.com/p/f69852835699#fnref3
[Node] koa2 learn to use templates to change the suffix .html ejs approach (common code extraction)