本文介绍了呈现基本的HTML视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个基本的node.js应用程序,我试图使用Express框架下车。我有一个视图
文件夹,其中我有一个 index.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')
什么我在这里错过了吗?
解决方案
你可以让玉包含一个纯HTML页面:
in views / index.jade
include plain.html
在views / plain.html
!DOCTYPE html>
...
和app.js仍然可以渲染玉:
res.render(index)
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.
Below is my code.
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')
What am I missing here?
解决方案
You can have jade include a plain HTML page:
in views/index.jade
include plain.html
in views/plain.html
<!DOCTYPE html>
...
and app.js can still just render jade:
res.render(index)
这篇关于呈现基本的HTML视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!