Comments (4)
@luchanan 开一个repo写个demo,然后给我
from koa-generator.
这个问题demo: https://github.com/luchanan/koa2_hbs.git
其实我看了express-generator,他们用的hbs,已经对handlebars进行了高级封装吧,有继承layout的功能。然后我看了你这里只有handlebars这个东西,我在想是不是基础版,layout需要自己实现(如上面我改的)。后来我用了koa-hbs(支持koa2)来弄就可以了,解决了刷新报错的问题。因为我看koa-views参数比较少,koa-hbs的参数好像不能用在koa-views上,所以我进行了下面的修改
// app.js
const hbs = require('koa-hbs')
...
// app.use(views(__dirname + '/views', {
// extension: 'hbs',
// map: { hbs: 'handlebars' },
// defaultLayout: 'layout'
// }))
app.use(hbs.middleware({
viewPath: __dirname + '/views',
layoutsPath: __dirname + '/views',
}));
// index.hbs
{{!< layout }}
<h1>{{title}}</h1>
<p>Welcome to {{title}}</p>
请求高见
from koa-generator.
我安装啦 npm install -g koa-generator 之后 运行 koa koa2 && cd koa2 然后报错 koa: command not found ,我的是mac系统 node v8.2.1版本
from koa-generator.
@jane- 很奇怪啊,有更多信息么?
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
- 支持热更新吗?
- app.js中routes(router)似乎没对 HOT 3
- 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.