Evan You
8 years ago
2 changed files with 30 additions and 0 deletions
@ -1,5 +1,7 @@ |
|||
import Transition from './transition' |
|||
import TransitionControl from './transition-control' |
|||
|
|||
export default { |
|||
Transition, |
|||
TransitionControl |
|||
} |
|||
|
@ -0,0 +1,28 @@ |
|||
// import { emptyVNode } from 'core/vdom/vnode'
|
|||
|
|||
export default { |
|||
name: 'transition', |
|||
props: ['name', 'appear', 'tag'], |
|||
_abstract: true, |
|||
render (h) { |
|||
const children = this.$slots.default |
|||
const props = this.$options.propsData |
|||
if (!children || !children.length) { |
|||
return |
|||
} |
|||
for (let i = 0; i < children.length; i++) { |
|||
const child = children[i] |
|||
;(child.data || (child.data = {})).transition = props |
|||
} |
|||
if (children.length > 1) { |
|||
if (!props.tag) { |
|||
throw new Error('prop "tag" is required when <transition> contains more than one element.') |
|||
} |
|||
return h(props.tag, this.$vnode.data, children) |
|||
} else { |
|||
const child = children[0] |
|||
child.key = child.key || `__v${this._uid}__` |
|||
return child |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue