mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
fix: Fix Layouts transitions
This commit is contained in:
parent
e80a77782a
commit
fb44c2eb8e
@ -18,16 +18,20 @@ export default {
|
|||||||
head: <%= serialize(head).replace('titleTemplate(', 'function(') %>,
|
head: <%= serialize(head).replace('titleTemplate(', 'function(') %>,
|
||||||
render(h, props) {
|
render(h, props) {
|
||||||
<% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %>
|
<% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %>
|
||||||
const layoutEl = h(this.nuxt.err ? 'nuxt' : this.layout, {
|
const layoutEl = h(this.layout || 'nuxt')
|
||||||
|
const templateEl = h('div', {
|
||||||
|
domProps: {
|
||||||
|
id: '__layout'
|
||||||
|
},
|
||||||
key: this.layoutName
|
key: this.layoutName
|
||||||
})
|
}, [ layoutEl ])
|
||||||
|
|
||||||
const transitionEl = h('transition', {
|
const transitionEl = h('transition', {
|
||||||
props: {
|
props: {
|
||||||
name: '<%= layoutTransition.name %>',
|
name: '<%= layoutTransition.name %>',
|
||||||
mode: '<%= layoutTransition.mode %>'
|
mode: '<%= layoutTransition.mode %>'
|
||||||
}
|
}
|
||||||
}, [ layoutEl ])
|
}, [ templateEl ])
|
||||||
|
|
||||||
return h('div',{
|
return h('div',{
|
||||||
domProps: {
|
domProps: {
|
||||||
|
@ -2,26 +2,11 @@ export default {
|
|||||||
name: 'nuxt-child',
|
name: 'nuxt-child',
|
||||||
functional: true,
|
functional: true,
|
||||||
render (h, { parent, data }) {
|
render (h, { parent, data }) {
|
||||||
const nuxt = parent.$root.nuxt
|
|
||||||
const component = parent.$route.matched[0].components.default
|
|
||||||
|
|
||||||
const layoutUid = parent._uid
|
|
||||||
const layoutName = component.options ? component.options.layout : null
|
|
||||||
|
|
||||||
// If we're changing layout render the stored vnode
|
|
||||||
if (nuxt._layoutUid === layoutUid &&
|
|
||||||
nuxt._layoutName !== layoutName
|
|
||||||
) {
|
|
||||||
return nuxt._childVnode
|
|
||||||
}
|
|
||||||
|
|
||||||
nuxt._layoutUid = layoutUid
|
|
||||||
nuxt._layoutName = layoutName
|
|
||||||
|
|
||||||
data.nuxtChild = true
|
data.nuxtChild = true
|
||||||
const _parent = parent
|
const _parent = parent
|
||||||
const transitions = parent.$nuxt.nuxt.transitions
|
const transitions = parent.$nuxt.nuxt.transitions
|
||||||
const defaultTransition = parent.$nuxt.nuxt.defaultTransition
|
const defaultTransition = parent.$nuxt.nuxt.defaultTransition
|
||||||
|
|
||||||
let depth = 0
|
let depth = 0
|
||||||
while (parent) {
|
while (parent) {
|
||||||
if (parent.$vnode && parent.$vnode.data.nuxtChild) {
|
if (parent.$vnode && parent.$vnode.data.nuxtChild) {
|
||||||
@ -44,14 +29,12 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
nuxt._childVnode = h('transition', {
|
return h('transition', {
|
||||||
props: transitionProps,
|
props: transitionProps,
|
||||||
on: listeners
|
on: listeners
|
||||||
}, [
|
}, [
|
||||||
h('router-view', data)
|
h('router-view', data)
|
||||||
])
|
])
|
||||||
|
|
||||||
return nuxt._childVnode
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user