我的快递应用中存在问题。有一些ejs模板,其中css样式文件正确应用。例如" localhost *** / page",但是当我转到" localhost *** / page / secondpage"即使我申请,我的ejs也看不到风格。
一点代码 app.js
from datetime import datetime
today = datetime.now()
hour_min = [int(x) for x in "09:15".split(":")]
bus_time = today.replace(hour=hour_min[0], minute=hour_min[1], second=0, microsecond=0)
print(bus_time)
一些路线
app.use(express.static(path.join(__dirname, 'public')));
//some code
app.use('/', require('./routes/index'));
app.use('/events', require('./routes/events'));
localhost *** / events页面和下一页localhost *** / events / singleevent
的负责人const express = require('express');
const router = express.Router();
router.get('/', function (req, res, next) {
let query = *db query*;
res.locals.connection.query(query, function (error, results, fields) {
if (error) throw error;
res.render('index', { title: 'Events', data: results });
});
});
router.get('/:id', function (req, res) {
let query = *db query*;
res.locals.connection.query(query, function (error, results, fields) {
if (error) throw error;
res.render('singleevent', { title: 'Event', data: results });
});
});
答案 0 :(得分:0)
你能分享项目的树吗?
您要求提供与html文件相关的css文件。
因此,如果html文件放在事件下,则css文件应位于: /events/css/style.css 等
希望这会有所帮助;)