Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在expressjs中调用多个File.pug?_Javascript_Express_Pug - Fatal编程技术网

Javascript 如何在expressjs中调用多个File.pug?

Javascript 如何在expressjs中调用多个File.pug?,javascript,express,pug,Javascript,Express,Pug,我想调用几个.pug文件,使其动态运行。但是我犯了一个错误 res.render('layout'); res.render('body'); res.render('footer'); 有人知道如何克服这个问题吗?我不能调用多个.pug文件您可以使用您的pug文件(不是路由文件,而是您的pug文件)调用它 哈巴狗 nav.nav-top ul li.menu-item a(href='/').menu Home a(hr

我想调用几个.pug文件,使其动态运行。但是我犯了一个错误

res.render('layout');
res.render('body');
res.render('footer');

有人知道如何克服这个问题吗?我不能调用多个.pug文件

您可以使用您的pug文件(不是路由文件,而是您的pug文件)调用它

哈巴狗

nav.nav-top
    ul
        li.menu-item
            a(href='/').menu Home
            a(href='/dashboard').menu Dashboard
            a(href='/dashboard/thelist').menu thelist
            a(href='/login').menu Login
footer.pug

main.pug[布局文件]。注意包括部件(例如包括../部件/收割台顶部)。我的零件文件夹与我的布局文件夹不同。它只是意味着包含这个哈巴狗文件,它会得到你的另一个哈巴狗文件的内容。只需输入pugfilename

doctype html
html
    head
        title #{title} 23
        link(rel='stylesheet' href='/css/style.css')
        //- script(src='/js/main.js')
        //- script(src="https://code.jquery.com/jquery-3.1.0.min.js")
    body
        container.page
            include ../part/header-top
            include ../part/header-main
            h1 Hello main.pug
            block content
            br
            hr
            block kicker
        footer
            p Copyright © 2019
        script(src='/js/main.js')
在视图中,从路线渲染的pug文件。注意扩展,然后是pug文件布局文件的文件位置。我称我的布局文件为main,所以指向你这边的布局文件。块内容是页面的内容。它会将块内容放入布局页面,其中显示块内容

extends ../../template/layout/main

block content
    h1 View
    a(href="/dashboard/thelist") The List
注意:根据您的布局和文件夹结构,您的将与我的不同

如果您需要更多帮助,您需要提供文件夹结构的详细信息

如果您需要更多帮助,这是我的设置示例(关于mixin,但它解决了调用pug文件的问题):