In my app, I use the vue-router. Routes work when I pass them to the router with router.map({}), but they don't work when I pass them in the constructor. Any idea why this is?
// works:
const router = new VueRouter()
router.map({
'/user' : {
component : User,
subRoutes : {}
}
})
// does not work:
const router = new VueRouter({
routes : [
{
path : '/user',
component : User,
children : []
}
]
})
Currently there are 2 versions of Vue Router.
1st - Vue Router
0.7.xwhich only works with VueJS1.x.xversion.The working example you posted is Vue Router0.7.xversion syntax, so probably you are running VueJS1.x.xon your app.2nd - Vue Router
2.xwhich only works with VueJS2.x.x.The second non-working examplte is Vue Router2.xversion syntax.So make sure what VueJS version you are running, and then apply correct Vue Router Version, and use correct syntax.
Docs for Vue Router
2.x.x- https://router.vuejs.org/en/ Docs for Vue Router0.7.x- https://github.com/vuejs/vue-router/tree/1.0/docs/en