mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
wip: Add keep-alive prop to <nuxt/> and <nuxt-child/>
This commit is contained in:
parent
93f3082c43
commit
1ea0a9a6f2
@ -1,7 +1,8 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'nuxt-child',
|
name: 'nuxt-child',
|
||||||
functional: true,
|
functional: true,
|
||||||
render (h, { parent, data }) {
|
props: ['keepAlive'],
|
||||||
|
render (h, { parent, data, props }) {
|
||||||
data.nuxtChild = true
|
data.nuxtChild = true
|
||||||
const _parent = parent
|
const _parent = parent
|
||||||
const transitions = parent.$nuxt.nuxt.transitions
|
const transitions = parent.$nuxt.nuxt.transitions
|
||||||
@ -29,12 +30,18 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let routerView = [
|
||||||
|
h('router-view', data)
|
||||||
|
]
|
||||||
|
if (typeof props.keepAlive !== 'undefined') {
|
||||||
|
routerView = [
|
||||||
|
h('keep-alive', routerView)
|
||||||
|
]
|
||||||
|
}
|
||||||
return h('transition', {
|
return h('transition', {
|
||||||
props: transitionProps,
|
props: transitionProps,
|
||||||
on: listeners
|
on: listeners
|
||||||
}, [
|
}, routerView)
|
||||||
h('router-view', data)
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { compile } from '../utils'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'nuxt',
|
name: 'nuxt',
|
||||||
props: ['nuxtChildKey'],
|
props: ['nuxtChildKey', 'keepAlive'],
|
||||||
render(h) {
|
render(h) {
|
||||||
// If there is some error
|
// If there is some error
|
||||||
if (this.nuxt.err) {
|
if (this.nuxt.err) {
|
||||||
@ -17,7 +17,8 @@ export default {
|
|||||||
}
|
}
|
||||||
// Directly return nuxt child
|
// Directly return nuxt child
|
||||||
return h('nuxt-child', {
|
return h('nuxt-child', {
|
||||||
key: this.routerViewKey
|
key: this.routerViewKey,
|
||||||
|
props: this.$props
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
beforeCreate () {
|
beforeCreate () {
|
||||||
|
Loading…
Reference in New Issue
Block a user