我正在使用Express.js和Jade并遇到问题。我有6张图片,但其中2张不会出现在页面上。我可以去local:3000/images/a.png
查看所有内容,但不能在我的页面上看到它们吗?这是我的一些Jade HTML:
.span4
img(src='/images/a.png', class='img')
.span4
img(src='/images/b.png', class='img')
.span4
img(src='/images/c.png', class='img')
.row-fluid
.span4
img(src='/images/d.png', class='img')
.span4
img(scr='/images/e.png', class='img') # Not working
.span4
img(scr='/images/f.png', class='img') # Not working
如果有帮助,这是我的app.js
:
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon(__dirname + '/public/images/icon.ico'));
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.get('/users', user.list);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
其他人遇到这个?我该怎么办?
答案 0 :(得分:4)
呵呵,因为你的玉文件中有拼写错误。
仔细检查您的img
标签 - 它(如您所知)应该是 src 而不是 scr :
.span4
img(scr='/images/e.png', class='img') # Not working
.span4
img(scr='/images/f.png', class='img') # Not working