由于 "大小 "属性不是其父属性的 "自有属性",因此被拒绝访问以解析该属性。

问题描述 投票:0回答:1

我用的是 express-handlebars 包(版本。4.0.4),然后像这样渲染我的代码。

app.get("/", (req, res) => {
    res.render('index', { title: 'Snowy' }, {
      allowProtoMethodsByDefault: true,
      allowProtoPropertiesByDefault: true
    });
})

但我还是得到了同样的错误。Stackoverflow上的任何解决方案对我来说都没有用。

node.js handlebars.js express-handlebars
1个回答
0
投票

在你的情况下,你必须安装旧版本的handlebar。把这个粘贴到你的终端,它应该会安装正确版本的handlebars。


npm uninstall express-handlebars && npm install [email protected]


这个版本问题可能与你机器上的npm或node.js版本有关。

© www.soinside.com 2019 - 2024. All rights reserved.