[英]Node, express and jade: not loading css stylesheets
I just started a small project in node and express using jade as the view engine but it isn't working for some reason that I don't know... 我刚刚在node中启动了一个小项目,并表示使用jade作为视图引擎,但是由于某种原因,它不起作用,我不知道...
My view: 我的观点:
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')
I've used the mdl stylesheet from the official source to be sure that it wasn't a problem with my static folder route. 我已经使用了官方来源的mdl样式表来确保它不是我的静态文件夹路由的问题。
My Controller: 我的控制器:
export default class Dashboard {
constructor(req, res) {
res.render('admin/dashboard', {
title: 'Dashboard'
});
}
}
The Core: 核心:
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');
});
}
}
I don't see anything wrong but somehow the stylesheets aren't loading, however the script is loading fine and if I try to load the stylesheets directly they load just fine too. 我没有看到任何错误,但是某种程度上没有加载样式表,但是脚本可以很好地加载,如果我尝试直接加载样式表,它们也可以很好地加载。
Please, if anyone could help me I'd appreciate a lot! 请,如果有人可以帮助我,我将不胜感激!
Thanks in advance. 提前致谢。
It should be rel
not ref
它应该是
rel
不ref
link(rel='stylesheet', href='/public/css/style.css')
^^^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.