Evan You
9 years ago
8 changed files with 57 additions and 9 deletions
@ -1,5 +1,7 @@ |
|||
import transitionControl from './transition-control' |
|||
import vKeepAlive from './keep-alive' |
|||
import vTransitionControl from './transition-control' |
|||
|
|||
export default { |
|||
transitionControl |
|||
vKeepAlive, |
|||
vTransitionControl |
|||
} |
|||
|
@ -0,0 +1,22 @@ |
|||
export default { |
|||
created () { |
|||
this.cache = Object.create(null) |
|||
}, |
|||
render () { |
|||
const childNode = this.$slots.default[0] |
|||
const cid = childNode.componentOptions.Ctor.cid |
|||
if (this.cache[cid]) { |
|||
const child = childNode.child = this.cache[cid].child |
|||
childNode.elm = this.$el = child.$el |
|||
} else { |
|||
this.cache[cid] = childNode |
|||
} |
|||
childNode.data.keepAlive = true |
|||
return childNode |
|||
}, |
|||
beforeDestroy () { |
|||
for (const key in this.cache) { |
|||
this.cache[key].child.$destroy() |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue