我在鏈接我的頁面上的css/js時遇到問題。 鏈接上localhost:5000/books/1
不工作 但頁面localhost:5000/books/
工作node.js(express)鏈接css/js
app.use(express.static(__dirname + "/public"));
bookRouter.route('/')
.get(function(req,res){
res.render('books',{title:"Tytuł", nav:[
{
Link: "/Books",
Text: "Books"
},{
Link: "/Authors",
Text: "Authors"
}],
books: books
});
});
bookRouter.route('/:id')
.get(function(req,res){
var id = req.params.id;
res.render('bookView',{title:"Tytuł", nav:[
{
Link: "/Books",
Text: "Books"
},{
Link: "/Authors",
Text: "Authors"
}],
book: books[id]
});
});
app.use('/books',bookRouter);
路線上工作而不是鏈接的CSS/JSS。它在尋找http://localhost:5000/books/lib/bootstrap/dist/css/bootstrap.min.css
請張貼路由'/ books /:id'的代碼... –