Comments (3)
@IanLew 贴具体代码,app.use(index.routes(), index.allowedMethods());的目的是注册路由
from koa-generator.
在生成的app.js中,const routes = require('./routes')
,routes目录下有很多路由,然后app.js中有这么段代码routes(router)
。我的理解是这段代是为注册routes目录下的所有路由,我不理解的是下面的路由文件都是这样的:
module.exports = (router) => { router.get('/welcome', async function (ctx, next) { ctx.state = { title: 'koa2 title' }; await ctx.render('welcome', {title: ctx.state}); }) }
如果我理解没错,这样子并不能成功吧
from koa-generator.
之前是照着一个教程做的,装的包是koa2-generator。刚刚我装的包是koa-generator,代码风格和之前的包也不一样。
from koa-generator.
Related Issues (20)
- package.json的一点小问题 HOT 4
- 请问为什么app.js里面的语句都没有;为结尾 HOT 2
- 样式怎么编译? HOT 1
- 引入webpack配置
- 是否有计划集成eslint
- add .gitignore && readme.md
- npm WARN deprecated [email protected]: This package is no longer maintained
- "狼叔":请教一下,如何自己写一个这样的应用生成工具 HOT 1
- 无法创建项目 HOT 2
- 为啥把runkoa去掉了?
- 建议koa2-generator使用 koa-body 因为 koa-bodyparser 不支持上传文件解析
- app中使用koa-router方法无效? HOT 1
- 支持热更新吗?
- centos npm install 失败 HOT 1
- Action required: Greenkeeper could not be activated 🚨
- @koa/router HOT 2
- 还在更新吗,koa版本都2.13.1了 HOT 1
- app.js 文件中关于路由的 use 问题
- 服务都跑不起来了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa-generator.