【发布时间】:2020-09-27 02:49:51
【问题描述】:
我正在开发 nodejs 应用程序。并想在网页中显示 Mongoose 结果。模板引擎是快递车把。
data= [
{name: 'some name', image: '/some_name.jpg', location: 'some location'},
{name: 'some name2', image: '/some_name2.jpg', location: 'some location2'},
{name: 'some name3', image: '/some_name3.jpg', location: 'some location3'}
]
我想在车把部分呈现数据。起初,我使用#each 迭代每个对象并将该对象传递给部分对象。下面是我正在做的代码。
{{#each data}}
{{> somePartial this}}
{{/each}}
在somePartial我想访问对象的属性。
<h5>Name: {{this.name}}</h5>
<h5>Image: {{this.image}}</h5>
<h5>Location: {{this.location}}</h5>
我在浏览器中看不到任何值呈现。在服务器控制台中,我收到一些警告或类似Handlebars: Access has been denied to resolve the property 'xxxx' because it is not 'own property' of its parent.。
【问题讨论】:
-
不应该是
{{#each data}}吗? -
我忘记放在那里.. 现在看看
标签: node.js express handlebars.js partials express-handlebars