【发布时间】:2017-05-29 22:40:15
【问题描述】:
当我尝试联系 http://localhost:3000/contato/1 时,我收到了下面的错误
GET http://localhost:3000/contato/static/bootstrap/dist/css/bootstrap.min.css 404 (Not Found)
这是由这条路线定义的:
app.route('/contato/:id')
.get(autenticar, contatos.show);
在其他没有 :id 参数的路由中,css 渲染得很好。
我正在使用 Pug 开发页面,并通过公共文件夹提供静态文件,使用:
app.use('/static', express.static(__dirname + '/public'));
我的 header.pug,我在每一页中扩展。
doctype html
html
head
link(href='static/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet')
meta(charset='utf-8')
meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no")
title Ntalk - Agenda de Contatos
body
div(class='container')
block content
出现错误的路线:
show.pug
include ../header
block content
div(class='row')
div(class='col-md-6 offset-md-3')
section(class='container')
header
h2 Ntalk - Dados do contato
【问题讨论】: