chore(Collapse): use relation

This commit is contained in:
chenjiahan 2020-09-25 14:15:57 +08:00
parent a1bca37a45
commit bcd8f4515b
2 changed files with 4 additions and 8 deletions

View File

@ -5,7 +5,7 @@ import { createNamespace } from '../utils';
import { raf, doubleRaf } from '../utils/dom/raf';
// Composition
import { useParent } from '../composition/use-parent';
import { useParent } from '../composition/use-relation';
import { useLazyRender } from '../composition/use-lazy-render';
// Components

View File

@ -1,6 +1,6 @@
import { provide, reactive } from 'vue';
import { createNamespace } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { useChildren } from '../composition/use-relation';
const [createComponent, bem] = createNamespace('collapse');
@ -19,7 +19,7 @@ export default createComponent({
emits: ['change', 'update:modelValue'],
setup(props, { emit, slots }) {
const children = reactive([]);
const { linkChildren } = useChildren(COLLAPSE_KEY);
const toggle = (name, expanded) => {
const { accordion, modelValue } = props;
@ -55,11 +55,7 @@ export default createComponent({
return accordion ? modelValue === name : modelValue.indexOf(name) !== -1;
};
provide(COLLAPSE_KEY, {
toggle,
children,
isExpanded,
});
linkChildren({ toggle, isExpanded });
return () => (
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}>