我正在关注YouTube上的一个教程,该教程告诉我制作侧面导航列表,并且在我遵循它时,出现了一个我不知道如何解决的错误。
简而言之,错误显示为:
37 | h3 = sideNavigationList [landingPage] .title 无法正确读取未定义的“标题”。
这是我名为“ nav.pug”的文件的代码:
-
var sideNavigationList = {
'Home': {
title: 'HTML and CSS',
linkList: [
{label: 'Learn HTML', link: '/html'},
{label: 'Learn CSS', link: '/css'},
{label: 'Learn JavaScript', link: '/javascript'},
]
},
'HTML': {
title: 'HTML Tutorial',
linkList: [
{label: 'HTML Elements', link: '/html/elements'},
{label: 'HTML Attributes', link: '/html/attributes'},
{label: 'HTML Headings', link: '/html/headings'},
]
},
'CSS': {
title: 'CSS Tutorial',
linkList: [
{label: 'CSS Colors', link: '/css/colors'},
{label: 'CSS Backgrounds', link: '/css/backgrounds'},
{label: 'CSS Borders', link: '/css/borders'},
]
},
'JavaScript': {
title: 'JavaScript Tutorial',
linkList: [
{label: 'JavaScript Comments', link: '/javascript/comments'},
{label: 'JavaScript Variables', link: '/javascript/variables'},
{label: 'JavaScript Operators', link: '/javascript/operators'},
]
},
}
nav
h3=sideNavigationList[landingPage].title
each navigation in sideNavigationList[landingPage].linkList
a(href=navigation.link)=navigation.label
//- a(href="/html") Learn HTML
//- a(href="/css") Learn CSS
//- a(href="/javascript") Learn JavaScript
有人可以告诉我哪里出了问题以及如何解决?非常感谢你。 :)