mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Custom route example
This commit is contained in:
parent
a31dc539cc
commit
36f3d48ece
@ -102,4 +102,19 @@ a, a:hover
|
||||
.fade-enter, .fade-leave-active {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.bounce-enter-active {
|
||||
animation: bounce-in .8s;
|
||||
}
|
||||
.bounce-leave-active {
|
||||
animation: bounce-out .5s;
|
||||
}
|
||||
@keyframes bounce-in {
|
||||
0% { transform: scale(0) }
|
||||
100% { transform: scale(1) }
|
||||
}
|
||||
@keyframes bounce-out {
|
||||
0% { transform: scale(1) }
|
||||
100% { transform: scale(0) }
|
||||
}
|
||||
</style>
|
||||
|
@ -11,5 +11,6 @@ module.exports = {
|
||||
'/projects/:slug': [{slug: 'toto'}, {slug: 'titi'}, {slug: 'tutu'}]
|
||||
}
|
||||
},
|
||||
transition: 'fade'
|
||||
transition: 'fade',
|
||||
loading: false
|
||||
}
|
||||
|
@ -5,14 +5,11 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
<router-link :to="{ name: 'posts-slug-name', params: { name: 'foo'} }">
|
||||
Foo
|
||||
</router-link>
|
||||
<router-link :to="{ name: 'posts-slug-name', params: { name: 'bar'} }">
|
||||
Bar
|
||||
</router-link>
|
||||
<nuxt-link :to="{ name: 'posts-slug-name', params: { name: 'foo'} }">Foo</nuxt-link>
|
||||
<nuxt-link :to="{ name: 'posts-slug-name', params: { name: 'bar'} }">Bar</nuxt-link>
|
||||
<nuxt-link :to="{ name: 'posts-slug-comments' }">Comments</nuxt-link>
|
||||
</p>
|
||||
<router-view></router-view>
|
||||
<nuxt-child :key="$route.params.name"></nuxt-child>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -7,6 +7,41 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transition: {
|
||||
name: 'bounce',
|
||||
// css: true,
|
||||
beforeEnter (el) {
|
||||
console.log('Before enter');
|
||||
},
|
||||
enter (el) {
|
||||
console.log('Enter')
|
||||
// done()
|
||||
},
|
||||
afterEnter (el) {
|
||||
console.log('After enter')
|
||||
},
|
||||
enterCancelled (el) {
|
||||
console.log('Enter cancelled')
|
||||
},
|
||||
beforeLeave (el) {
|
||||
console.log('Before leave')
|
||||
},
|
||||
leave (el) {
|
||||
console.log('Leave')
|
||||
// done()
|
||||
},
|
||||
afterLeave (el) {
|
||||
console.log('After leave')
|
||||
},
|
||||
leaveCancelled (el) {
|
||||
console.log('Leave cancelled')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
p
|
||||
{
|
||||
|
@ -3,3 +3,9 @@
|
||||
Comments only
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<router-link :to="{ name: 'users-id', params: { id: user.id } }">{{ user.name }}</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<router-view></router-view>
|
||||
<nuxt-child :key="$route.params.id"></nuxt-child>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -46,21 +46,4 @@ export default {
|
||||
.router-link-active {
|
||||
color: #41b883 !important;
|
||||
}
|
||||
.bounce-enter-active {
|
||||
animation: bounce-in .8s;
|
||||
}
|
||||
.bounce-leave-active {
|
||||
animation: bounce-out .5s;
|
||||
}
|
||||
@keyframes bounce-in {
|
||||
0% { transform: scale(0) }
|
||||
50% { transform: scale(1.5) }
|
||||
100% { transform: scale(1) }
|
||||
}
|
||||
@keyframes bounce-out {
|
||||
0% { transform: scale(1) }
|
||||
50% { transform: scale(1.5) }
|
||||
100% { transform: scale(0) }
|
||||
}
|
||||
|
||||
</style>
|
||||
|
@ -12,6 +12,10 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
transition (to, from) {
|
||||
if (!from || !from.params.id || !to.params.id) return 'fade'
|
||||
return +to.params.id > +from.params.id ? 'slide-left' : 'slide-right'
|
||||
},
|
||||
data ({ params, error }) {
|
||||
return axios.get(`https://jsonplaceholder.typicode.com/users/${params.id}`)
|
||||
.then((res) => { return { user: res.data } })
|
||||
@ -28,10 +32,16 @@ export default {
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
min-height: 440px;
|
||||
transition: all .5s cubic-bezier(.55,0,.1,1);
|
||||
}
|
||||
.slide-left-enter,
|
||||
.slide-right-leave-active {
|
||||
opacity: 0;
|
||||
transform: translate(30px, 0);
|
||||
}
|
||||
.slide-left-leave-active,
|
||||
.slide-right-enter {
|
||||
opacity: 0;
|
||||
transform: translate(-30px, 0);
|
||||
}
|
||||
/*.user {
|
||||
text-align: center;
|
||||
margin-top: 100px;
|
||||
font-family: sans-serif;
|
||||
}*/
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user