Javascript 节点、express和jade:不加载css样式表
我刚刚在node和express中启动了一个小项目,使用jade作为视图引擎,但由于某种原因,它无法工作,我不知道 我的看法是:Javascript 节点、express和jade:不加载css样式表,javascript,node.js,express,pug,stylesheet,Javascript,Node.js,Express,Pug,Stylesheet,我刚刚在node和express中启动了一个小项目,使用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-pin
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')
^^^
答案总是更多的咖啡-D