[英]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')
^^^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.