scoop position nested routes

This commit is contained in:
Alexandre Chopin 2016-12-11 16:40:18 +01:00
parent ce0a89508e
commit d09fdfb78e
4 changed files with 20 additions and 12 deletions

View File

@ -1,5 +0,0 @@
<template>
<div>
Comments list
</div>
</template>

View File

@ -0,0 +1,5 @@
<template>
<div class="container">
Comments only
</div>
</template>

View File

@ -1,9 +1,10 @@
<template>
<div class="user">
<div class="container">
<h2>User</h2>
<h3>{{ name }}</h3>
<h4>@{{ username }}</h4>
<p>Email : {{ email }}</p>
<p><router-link to="/">List of users</router-link></p>
<p><router-link to="/users">List of users</router-link></p>
</div>
</template>
@ -22,9 +23,14 @@ export default {
</script>
<style scoped>
.user {
.container
{
text-align: center;
overflow: hidden;
}
/*.user {
text-align: center;
margin-top: 100px;
font-family: sans-serif;
}
}*/
</style>

View File

@ -16,7 +16,6 @@ function recursiveRoutes(routes, tab) {
res += tab + '\tcomponent: ' + route._name
res += (route.name) ? ',\n\t' + tab + 'name: ' + JSON.stringify(route.name) : ''
res += (route.alias) ? ',\n\t' + tab + 'alias: ' + JSON.stringify(route.alias) : ''
res += (route.redirect) ? ',\n\t' + tab + 'redirect: ' + JSON.stringify(route.redirect) : ''
res += (route.meta) ? ',\n\t' + tab + 'meta: ' + JSON.stringify(route.meta) : ''
res += (route.children) ? ',\n\t' + tab + 'children: [\n' + recursiveRoutes(routes[i].children, tab + '\t\t') + '\n\t' + tab + ']' : ''
res += '\n' + tab + '}' + (i + 1 === routes.length ? '' : ',\n')
@ -33,8 +32,11 @@ const scrollBehavior = (to, from, savedPosition) => {
// savedPosition is only available for popstate navigations.
return savedPosition
} else {
// Scroll to the top by default
let position = { x: 0, y: 0 }
let position = {}
// if no children detected
if (to.matched.length < 2) {
position = { x: 0, y: 0 }
}
// if link has anchor, scroll to anchor by returning the selector
if (to.hash) {
position = { selector: to.hash }