node.js:vash呈现错误



我在使用vash的node.js中遇到渲染错误。我真的很难弄清楚问题出在哪里。下面是错误和导致错误的代码。

TypeError: Problem while rendering template at line 4, character 2.
 Original message: object is not a function. Context: 2 |
 @html.block('body', function(model){ 3 | <p>@model.title </p> > 4 |
 }); 5 | }); 6 | 7 | at helpers.extend.model
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:2213:4)
 at Object.vash.loadFile
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:2072:10)
 at helpers.extend
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:2190:8)
 at eval (eval at <anonymous>
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:1820:24),
 <anonymous>:7:21) at vash.link.linked
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:1860:12)
 at vash.renderFile
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:2082:21)
 at Object.vash.loadFile
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:2070:10)
 at View.vash.renderFile [as engine]
 (C:Usersuser009Dropboxcppnode_modulesvashbuildvash.js:2078:8)
 at View.render
 (C:Usersuser009Dropboxcppnode_modulesexpresslibview.js:76:8)
 at Function.app.render
 (C:Usersuser009Dropboxcppnode_modulesexpresslibapplication.js:502:10)

路由器:

app.get("/", function (request, response) {
    response.render('index', {title: 'letsdoit'});
});

布局.vash

<!DOCTYPE html>
<html>
<head><link href="/css/site.css" rel="stylesheet" />
<title>@model.title</title></head>
<body><div> @html.block('body') </div></body></html>

index.vash

@html.extend('layout', function(model){
    @html.block('body', function(model){
        <p>@model.title </p>
    });
});

在index.vash文件中,确保layout.vash文件的路径正确。

例如,如果视图文件夹结构是views/home/layout.vash和views/home/index.vash,那么:

@html.extend('layout', function(model){

应该是:

@html.extend('home/layout', function(model){

希望能有所帮助。

相关内容

  • 没有找到相关文章

最新更新