Recently, I started delving into VueJS and decided to create a new Vue application using vue-cli. After making a few modifications, this is what my router.js looks like:
import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import Panel from '@/components/Panel'
import Search from '@/components/Search'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'Hello',
component: Hello
},
{
path: '/panel',
name: 'Panel',
component: Panel,
children: {
path: 'search',
component: Search
}
}
]
})
Interestingly, my Panel.vue renders perfectly fine even without including a 'children' key in the router object. Here is the code snippet:
<template>
<div class="panel">
<h1>Panel</h1>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'panel',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
The Search.vue file follows a similar structure:
<template>
<div class="search">
<h1>Search</h1>
<p>Lorem ipsum ...</p>
</div>
</template>
<script>
export default {
name: 'search',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
Despite configuring the routes as per the guidelines mentioned here, I encountered the following error:
vue-router.common.js?37ec:598Uncaught TypeError: route.children.some is not a function
This error led to a blank page being displayed. I'm aiming for the scenario where, when accessing localhost:port/#/panel
, only the Panel
component is shown. On the other hand, navigating to localhost:port/#/panel/search
should display the Search
component, enclosed within the Panel
component. This is crucial since the intention is not to visit just /panel
.
Can someone offer guidance or assistance in resolving this issue?