diff --git a/src/action-bar-button/index.js b/src/action-bar-button/index.js index 0c7cba926..4699e16ef 100644 --- a/src/action-bar-button/index.js +++ b/src/action-bar-button/index.js @@ -1,7 +1,7 @@ import { ref, computed } from 'vue'; import { createNamespace } from '../utils'; import { route, routeProps } from '../utils/router'; -import { useChildren } from '../api/use-relation'; +import { useParent } from '../api/use-relation'; import { ACTION_BAR_KEY } from '../action-bar'; import Button from '../button'; @@ -19,18 +19,20 @@ export default createComponent({ }, setup(props, { slots }) { - const { children, index } = useChildren(ACTION_BAR_KEY, ref(true)); + const { parent, index } = useParent(ACTION_BAR_KEY, ref(true)); const isFirst = computed(() => { - if (children) { - const prev = children.value[index.value - 1]; + if (parent) { + const children = parent.children.value; + const prev = children[index.value - 1]; return !(prev && prev.value); } }); const isLast = computed(() => { - if (children) { - const next = children.value[index.value + 1]; + if (parent) { + const children = parent.children.value; + const next = children[index.value + 1]; return !(next && next.value); } }); diff --git a/src/action-bar-icon/index.js b/src/action-bar-icon/index.js index 82b7c1b8d..009b3c325 100644 --- a/src/action-bar-icon/index.js +++ b/src/action-bar-icon/index.js @@ -1,7 +1,7 @@ import { ref } from 'vue'; import { createNamespace } from '../utils'; import { route, routeProps } from '../utils/router'; -import { useChildren } from '../api/use-relation'; +import { useParent } from '../api/use-relation'; import { ACTION_BAR_KEY } from '../action-bar'; import Icon from '../icon'; import Badge from '../badge'; @@ -20,7 +20,7 @@ export default createComponent({ }, setup(props, { slots }) { - useChildren(ACTION_BAR_KEY, ref()); + useParent(ACTION_BAR_KEY, ref()); function genIcon() { const { dot, badge, icon, color, iconClass } = props; diff --git a/src/action-bar/index.js b/src/action-bar/index.js index 1839dda5e..ee2623114 100644 --- a/src/action-bar/index.js +++ b/src/action-bar/index.js @@ -1,5 +1,5 @@ import { createNamespace } from '../utils'; -import { useParent } from '../api/use-relation'; +import { useChildren } from '../api/use-relation'; const [createComponent, bem] = createNamespace('action-bar'); @@ -14,7 +14,7 @@ export default createComponent({ }, setup(props, { slots }) { - useParent(ACTION_BAR_KEY); + useChildren(ACTION_BAR_KEY); return () => (