vue的计算属性用于简单运算,在模版中太多的逻辑会难以维护,例如:
1 | <div id="example"> |
这个地方逻辑是字符串反转,如果多次使用会造成不好维护的现象,而且逻辑代码写在模版里可读性并不是很好。
1.npm install -g koa-generator
2.koa2 项目名称,如果需要ejs引擎koa2 -e 项目名称
3.cd 项目名称
4.npm install
5.npm install –update-binary
6.npm run dev
小知识点:对于start和test可以使用npm,对于dev和prd必须使用npm run来启动
1 | function pv(ctx){ |
1 | const router = require('koa-router')() |
1 | //在server/interface/city.js |
测试一下curl http://localhost:3000/city/list 或者浏览器输入http://localhost:3000/city/list
Update your browser to view this website correctly. Update my browser now