为什么部分代码在 ExpressJS 中不起作用?
myModule.search location, item, (err, data) ->
if err?
res.end 'Error!'
else
res.write 'got here'
partial 'partials/table', {items: data, layout: false}
res.end()
return
我的服务器上出现以下错误:
partial('partials/table', {
^
ReferenceError: partial is not defined
知道吗?
myModule.search location, item, (err, data) ->
if err?
res.end 'Error!'
else
res.write 'got here'
partial 'partials/table', {items: data, layout: false}
res.end()
return
I get the following error on my server:
partial('partials/table', {
^
ReferenceError: partial is not defined
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然 guide 中的示例将其演示为全局函数,但我认为它实际上只能在视图:
您可以在
/examples/partials 下找到许多相关示例
在存储库中。然而,在您的脚本中,它是响应对象的一个方法:
While the examples in the guide demonstrate it as a global function, I think it's only actually available like this within a view:
You can find a number of examples of this under
/examples/partials
in the repository.Within your script, however, it's a method of the response object:
我发现它发生了一些变化。您需要研究扩展../布局、块内容并包含。
在以下位置搜索示例:
https://github.com/visionmedia/express/blob /master/examples/jade
I see that it changed a little. You need to investigate extends ../layout, block content and include.
Search for the examples in:
https://github.com/visionmedia/express/blob/master/examples/jade
3.0+ Express JS 版本不再提供部分功能。因此,您必须检查包含相同概念的包含内容。
Partials are no longer available for 3.0+ Express JS version. So you have to check out for includes that contains the same conception.