2017-12-21 12 views
0

명시 적 앱에 문제가 있습니다. CSS 스타일 파일이 올바르게 적용된 ejs 템플릿이 있습니다. 예를 들어, "localhost ***/page",하지만 "localhost ***/page/secondpage"로 이동하면 내 ejs는 스타일을 적용해도 그것을 보지 못합니다.Ejs 파일에 CSS 스타일이 표시되지 않습니다

코드 의 조금

app.use(express.static(path.join(__dirname, 'public'))); 
//some code 
app.use('/', require('./routes/index')); 
app.use('/events', require('./routes/events')); 

일부 노선

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 }); 
    }); 
}); 

로컬 호스트의 헤드 ***/이벤트 페이지와 다음 페이지의 로컬 호스트 ***/이벤트/singleevent의를 app.js

<head> 
    <meta charset="UTF-8"> 
    <title> 
    <%= title %>|Minsk Events</title> 
    <link rel="stylesheet" href="css/style.css"> 
</head> 

There are my dirs

답변

0

프로젝트 트리를 공유 할 수 있습니까?

html 파일과 관련된 CSS 파일을 요청했습니다. HTML 파일은 이벤트 아래에 배치되는 경우

그래서, 다음의 CSS 파일에 있어야합니다 :이 도움 등 /events/css/style.css

희망) 기본 디렉토리에

+0

내가있다 : public/css/style.css 및 views/events.ejs 및 views/singleevent.ejs –