mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(Collapse): use relation
This commit is contained in:
parent
a1bca37a45
commit
bcd8f4515b
@ -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
|
||||
|
@ -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 }]}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user