mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
scoop position nested routes
This commit is contained in:
parent
ce0a89508e
commit
d09fdfb78e
@ -1,5 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
Comments list
|
|
||||||
</div>
|
|
||||||
</template>
|
|
5
examples/custom-routes/pages/posts/_slug/comments.vue
Normal file
5
examples/custom-routes/pages/posts/_slug/comments.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
Comments only
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="user">
|
<div class="container">
|
||||||
|
<h2>User</h2>
|
||||||
<h3>{{ name }}</h3>
|
<h3>{{ name }}</h3>
|
||||||
<h4>@{{ username }}</h4>
|
<h4>@{{ username }}</h4>
|
||||||
<p>Email : {{ email }}</p>
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -22,9 +23,14 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.user {
|
.container
|
||||||
|
{
|
||||||
|
text-align: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
/*.user {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 100px;
|
margin-top: 100px;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
}
|
}*/
|
||||||
</style>
|
</style>
|
@ -16,7 +16,6 @@ function recursiveRoutes(routes, tab) {
|
|||||||
res += tab + '\tcomponent: ' + route._name
|
res += tab + '\tcomponent: ' + route._name
|
||||||
res += (route.name) ? ',\n\t' + tab + 'name: ' + JSON.stringify(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.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.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 += (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')
|
res += '\n' + tab + '}' + (i + 1 === routes.length ? '' : ',\n')
|
||||||
@ -33,8 +32,11 @@ const scrollBehavior = (to, from, savedPosition) => {
|
|||||||
// savedPosition is only available for popstate navigations.
|
// savedPosition is only available for popstate navigations.
|
||||||
return savedPosition
|
return savedPosition
|
||||||
} else {
|
} else {
|
||||||
// Scroll to the top by default
|
let position = {}
|
||||||
let position = { x: 0, y: 0 }
|
// 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 link has anchor, scroll to anchor by returning the selector
|
||||||
if (to.hash) {
|
if (to.hash) {
|
||||||
position = { selector: to.hash }
|
position = { selector: to.hash }
|
||||||
|
Loading…
Reference in New Issue
Block a user