1
元のapp.getが呼び出される前にいくつかの処理を実行しようとしています。Expressjs ejs fn.applyエラー 'ビューがコンストラクタではありません'
私はthisページを見つけました。私は彼らがやったことを試してみましたが、ほとんどはうまくいっていました。レンダリングエンジンを使用しようとします。
私は(app
がexpress()
の結果である)を使用しているコード:
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は私に、このエラーを与える:TypeError: View is not a constructor
は、私はこの問題を解決することができますどのように誰もが知っていますか?
PS:/views/index.ejs
は
! ありがとうございます! – CreasolDev