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';
|
import { raf, doubleRaf } from '../utils/dom/raf';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import { useParent } from '../composition/use-parent';
|
import { useParent } from '../composition/use-relation';
|
||||||
import { useLazyRender } from '../composition/use-lazy-render';
|
import { useLazyRender } from '../composition/use-lazy-render';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { provide, reactive } from 'vue';
|
|
||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { BORDER_TOP_BOTTOM } from '../utils/constant';
|
import { BORDER_TOP_BOTTOM } from '../utils/constant';
|
||||||
|
import { useChildren } from '../composition/use-relation';
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('collapse');
|
const [createComponent, bem] = createNamespace('collapse');
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export default createComponent({
|
|||||||
emits: ['change', 'update:modelValue'],
|
emits: ['change', 'update:modelValue'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const children = reactive([]);
|
const { linkChildren } = useChildren(COLLAPSE_KEY);
|
||||||
|
|
||||||
const toggle = (name, expanded) => {
|
const toggle = (name, expanded) => {
|
||||||
const { accordion, modelValue } = props;
|
const { accordion, modelValue } = props;
|
||||||
@ -55,11 +55,7 @@ export default createComponent({
|
|||||||
return accordion ? modelValue === name : modelValue.indexOf(name) !== -1;
|
return accordion ? modelValue === name : modelValue.indexOf(name) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
provide(COLLAPSE_KEY, {
|
linkChildren({ toggle, isExpanded });
|
||||||
toggle,
|
|
||||||
children,
|
|
||||||
isExpanded,
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}>
|
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user