javascript - Vue路由器加载子路由失败
问题描述
我正在尝试在我的 Vue 应用程序中设置路由器。在我开始尝试实施儿童路线之前,一切似乎都运行良好。现在,当我尝试访问子路由时,我收到一条错误消息以及一些警告: 当我单击子路由器链接时会发生什么
我的路由器设置:
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', redirect: '/welcome' },
{
name: 'welcome',
path: '/welcome',
component: WelcomePage
},
{
name:'noteLists',
path: '/noteLists',
component: NoteListLinks,
children: [
{
name:'noteListSheets',
path: ':id',
components: FullNoteSheet
}
]
}
],
linkActiveClass: 'active'
});
所有其他路由链接工作正常。
使用和渲染子链接的组件模板如下所示:
<template>
<router-link
:to="setNoteListLink(entry.id)"
:key=entry.id
v-for="entry in notesListEntry"
>
{{entry.name}}
</router-link>
<router-view></router-view>
函数 setNoteListLink 只是创建一个类似'/noteList/1'的链接。
该错误说它“无法读取未定义的属性'writeDebug'”并且writeDebug是组件上的一种方法,当我单击路由(FullNoteSheet)时它会尝试加载,所以我认为组件有问题而不是路由器。但是,如果我尝试单独加载它,只需将它放在 App 组件模板中,组件就可以正常工作。
如果您处理过此类问题并知道解决方案,请告诉我。
解决方案
noteListSheets
您在路线上有错字;应该component: FullNoteSheet
不是components: FullNoteSheet
推荐阅读
- json - Classroom API 返回错误的截止日期
- javascript - 我想要卡片中每个元素的事件监听器
- r - input$sidebarItemExpanded 不适用于 R Shiny 中的 convertMenuItem
- css - 有没有办法修复css中自定义下拉箭头的大小?
- python - 如何在此文件中的每 4 个元素之后将输出附加到 txt 文件
- excel - 为 VBA 宏创建字典对象时遇到问题
- android - 我可以通过 AWS 接收 Android 推送通知吗?
- razor - Blazor/Razor:带枚举的 InputSelect?
- javascript - 枚举与字符串文字最佳实践
- python - QTabWidget 不允许我使用自定义类