Node、express 和 jade:未加载 css 个样式表
Node, express and jade: not loading css stylesheets
我刚刚在 node 中启动了一个小项目,并使用 jade 作为视图引擎进行了表达,但由于某种我不知道的原因它无法正常工作...
我的看法:
doctype html
html
head
meta(charset='utf-8')
title= 'Admin / ' + title
link(ref='stylesheet', href='https://storage.googleapis.com/code.getmdl.io/1.0.5/material.indigo-pink.min.css')
link(ref='stylesheet', href='/public/css/style.css')
body
block content
script(src='/public/material-design-lite/material.min.js')
我使用了官方来源的 mdl 样式表来确保我的静态文件夹路由没有问题。
我的控制器:
export default class Dashboard {
constructor(req, res) {
res.render('admin/dashboard', {
title: 'Dashboard'
});
}
}
核心:
import express from 'express';
import {Routes} from './config/config';
export default class Core {
constructor() {
this.app = express();
this.app.set('view engine', 'jade');
this.app.set('views', __dirname + '/views');
let routes = new Routes();
this.app.use('/', routes.get());
this.app.use('/public', express.static('public'));
this.app.use('/public/material-design-lite', express.static('node_modules/material-design-lite'));
this.app.listen('3000', () => {
console.log('Listening on ::3000');
});
}
}
我没有发现任何错误,但不知何故样式表没有加载,但是脚本加载正常,如果我尝试直接加载样式表,它们也可以正常加载。
拜托,如果有人能帮助我,我将不胜感激!
提前致谢。
应该是rel
不是ref
link(rel='stylesheet', href='/public/css/style.css')
^^^
我刚刚在 node 中启动了一个小项目,并使用 jade 作为视图引擎进行了表达,但由于某种我不知道的原因它无法正常工作...
我的看法:
doctype html
html
head
meta(charset='utf-8')
title= 'Admin / ' + title
link(ref='stylesheet', href='https://storage.googleapis.com/code.getmdl.io/1.0.5/material.indigo-pink.min.css')
link(ref='stylesheet', href='/public/css/style.css')
body
block content
script(src='/public/material-design-lite/material.min.js')
我使用了官方来源的 mdl 样式表来确保我的静态文件夹路由没有问题。
我的控制器:
export default class Dashboard {
constructor(req, res) {
res.render('admin/dashboard', {
title: 'Dashboard'
});
}
}
核心:
import express from 'express';
import {Routes} from './config/config';
export default class Core {
constructor() {
this.app = express();
this.app.set('view engine', 'jade');
this.app.set('views', __dirname + '/views');
let routes = new Routes();
this.app.use('/', routes.get());
this.app.use('/public', express.static('public'));
this.app.use('/public/material-design-lite', express.static('node_modules/material-design-lite'));
this.app.listen('3000', () => {
console.log('Listening on ::3000');
});
}
}
我没有发现任何错误,但不知何故样式表没有加载,但是脚本加载正常,如果我尝试直接加载样式表,它们也可以正常加载。
拜托,如果有人能帮助我,我将不胜感激!
提前致谢。
应该是rel
不是ref
link(rel='stylesheet', href='/public/css/style.css')
^^^