1
원래 app.get이 호출되기 전에 몇 가지 작업을 수행하려고합니다.Expressjs ejs fn.apply 오류 '보기가 생성자가 아닙니다'
this 페이지를 찾았는데, 내가 한 일을 시도해 보았습니다. 그리고 대부분은 효과적이었습니다. 렌더링 엔진을 사용하려고 할 때 기대했습니다.
내가 (app
이 express()
의 결과입니다) 사용하고 코드 : TypeError: View is not a constructor
는
사람이 내가이 문제를 해결할 수있는 방법을 알고 있나요 :
const express = require('express');
const app = express();
const ejs = require('ejs');
app.set('view engine', 'ejs');
var originalfoo = app.get;
app.get = function() {
// Do stuff before calling function
console.log(arguments);
// Call the function as it would have been called normally:
originalfoo.apply(this, arguments);
// Run stuff after, here.
};
app.get('/home', function (req, res) {
//res.send('hello world') // This works
res.render('index'); // This crashes
});
res.render 나를이 오류를 준다?
PS : /views/index.ejs
이
! 대단히 감사합니다 !! – CreasolDev