渲染基本的 HTML 视图?
我有一个基本的 node.js 应用程序,我正在尝试使用 Express 框架启动它.我有一个 views
文件夹,其中有一个 index.html
文件.但是我在加载网络浏览器时收到以下错误.
I have a basic node.js app that I am trying to get off the ground using Express framework. I have a views
folder where I have an index.html
file. But I receive the following error when loading the web browser.
错误:找不到模块html"
Error: Cannot find module 'html'
下面是我的代码.
var express = require('express');
var app = express.createServer();
app.use(express.staticProvider(__dirname + '/public'));
app.get('/', function(req, res) {
res.render('index.html');
});
app.listen(8080, '127.0.0.1')
我在这里错过了什么?
推荐答案
你可以让jade包含一个纯HTML页面:
You can have jade include a plain HTML page:
在views/index.jade中
in views/index.jade
include plain.html
在views/plain.html中
in views/plain.html
<!DOCTYPE html>
...
而 app.js 仍然可以只渲染玉:
and app.js can still just render jade:
res.render(index)
相关文章