【发布时间】:2020-06-10 09:42:58
【问题描述】:
我正在结合 Vuex 和 vue-router 构建一个 Vuetify 应用程序。一些视图使用默认的导航抽屉,但其他视图在其导航抽屉中有不同的项目。 This documentation say 我可以通过 props 来查看组件。所以我是这样实现的:
路由/index.js
{
path: '/courses/:courseId/lessons/:lessonId',
name: 'Course 1',
components: {
default: () => import('@/views/ViewLesson.vue'),
sidebar: () => import('@/components/CourseNavBar/CourseNavBar.vue')
},
props: {
items: [
{ text: "Link 1", href:"/link1" },
{ text: "Link 2", href:"/link2" }
]
}
}
src/App.vue
<template>
<v-app>
<v-app-bar
app
color="primary"
dark
>
<h1>My Project</h1>
</v-app-bar>
<v-navigation-drawer><router-view :items="items" name="sidebar"/></v-navigation-drawer>
<v-content>
<router-view />
</v-content>
</v-app>
</template>
但显然,
src/components/CourseNavBar.vue
<template>
<!-- <v-navigation-drawer :value="1"> -->
<v-list dense>
<navbar-item v-for="(item, i) in items" :key="i" :item="item" >
{{ item.text }}
</navbar-item>
</v-list>
<!-- </v-navigation-drawer> -->
</template>
<script>
import NavBarItem from './NavBarItem.vue'
export default {
props: {
items: Array
},
components: {
'navbar-item': NavBarItem
}
}
</script>
但<CourseNavBar> 的道具仍然未定义。我在这里做错了什么?
【问题讨论】:
标签: vue.js vuetify.js vue-router