我目前正在尝试学习 node.js,并且正在使用 express 和 jam。我正在尝试让 twitter 引导程序正常工作,但遇到了问题……这是我的错误:
ReferenceError: C:\Users\acraze\chatty\views\index.jade:4
2|
3| block content
> 4| div.top
5| form.form-horizontal(method="post", id="loginForm")
6| label Username
7| input.span3(id="username", type="text", name="User", placeholder="Enter your username")
这是我的index.js的样子:
var express = require("express");
var app = express();
var port =3700;
app.set('views', __dirname + '/views');
app.set('view engine', "jade");
app.engine('jade', require('jade').__express);
app.get("/", function(req, res){
res.render("index");
});
app.use(express.static(__dirname + '/public'));
var io = require('socket.io').listen(app.listen(port));
console.log("Listening on port " + port);
io.sockets.on('connection', function (socket) {
socket.emit('message', { message: 'welcome to the thunderdome lulz' });
socket.on('send', function (data) {
io.sockets.emit('message', data);
});
});
这是我的 layout.jade
!!!
html
head
title= title
link(rel='stylesheet', href='/bootstrap/css/bootstrap.min.css')
link(rel='stylesheet', href='/bootstrap/css/bootstrap-responsive.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
script(src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js')
script(src='/bootstrap/js/bootstrap.min.js')
body
block content
这是我的 index.jade
extends layout
block content
div.top
form.form-horizontal(method="post", id="loginForm")
label Username
input.span3(id="username", type="text", name="User", placeholder="Enter your username")
label Password
input.span3(id="password", type="password", name="Password")
input.btn(type="submit", value="Log In")
div.container
div.content
table.table.table-striped
thead
tr
th Table
th Heading
tbody
tr
td Test1
td Test2
tr
td Hello
td World
div.footer
这有什么关系res.render("index");
吗?我真的很困惑...我目前正在使用最新版本的 express、socket.io 和 jam...这有什么不同吗?