如何在 pug 中使用绝对路径?

问题描述

根据https://pugjs.org/language/includes.html,如果路径是绝对路径,我应该使用options.basedir

app.set("view engine","pug");
app.set("views",process.cwd() + "/src/views");
app.locals.basedir = process.cwd();

所以,我输入了 app.locals.basedir = process.cwd();

// uploadVideoBase.pug

extends /src/views/base.pug

block content 
    div
        section.userContainer
            div.userInfo
                include ../partials/showAvatar.pug
                span My Channel 
                span=user.username
            ul.userChoice
                li 
                    i.fas.fa-chalkboard
                    a(href="#")
                        span dashboard 
                li 
                    i.fas.fa-play-circle
                    a(href="#")
                        span content 
                li 
                    i.fab.fa-playstation
                    a(href="#")
                        span playList
        block dashboard

然后我在 extends /src/views/base.pug 处输入了 uploadVideoBase.pug

Error: ENOENT: no such file or directory,open 'C:\Users\kjkks\Documents\wetube\src\views\users\partials\showAvatar.pug'

但它给了我一个错误

enter image description here

我想通过使用 base.puguploadVideoBase.pug 使用 extends。我该怎么办?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)