mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
chore(Picker): use relation
This commit is contained in:
parent
e4b7952061
commit
dfad7b14af
@ -9,7 +9,8 @@ import { preventDefault } from '../utils/dom/event';
|
|||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import { useTouch } from '../composition/use-touch';
|
import { useTouch } from '../composition/use-touch';
|
||||||
import { useParent } from '../composition/use-parent';
|
import { useExpose } from '../composition/use-expose';
|
||||||
|
import { useParent } from '../composition/use-relation';
|
||||||
|
|
||||||
const DEFAULT_DURATION = 200;
|
const DEFAULT_DURATION = 200;
|
||||||
|
|
||||||
@ -278,7 +279,8 @@ export default createComponent({
|
|||||||
|
|
||||||
setIndex(state.index);
|
setIndex(state.index);
|
||||||
|
|
||||||
useParent(PICKER_KEY, {
|
useParent(PICKER_KEY);
|
||||||
|
useExpose({
|
||||||
state,
|
state,
|
||||||
setIndex,
|
setIndex,
|
||||||
getValue,
|
getValue,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ref, watch, computed, provide, reactive } from 'vue';
|
import { ref, watch, computed } from 'vue';
|
||||||
import { pickerProps, PICKER_KEY, DEFAULT_ITEM_HEIGHT } from './shared';
|
import { pickerProps, PICKER_KEY, DEFAULT_ITEM_HEIGHT } from './shared';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
@ -9,6 +9,7 @@ import { unitToPx } from '../utils/format/unit';
|
|||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import { useExpose } from '../composition/use-expose';
|
import { useExpose } from '../composition/use-expose';
|
||||||
|
import { useChildren } from '../composition/use-relation';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Loading from '../loading';
|
import Loading from '../loading';
|
||||||
@ -40,9 +41,12 @@ export default createComponent({
|
|||||||
emits: ['confirm', 'cancel', 'change'],
|
emits: ['confirm', 'cancel', 'change'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const children = reactive([]);
|
|
||||||
const formattedColumns = ref([]);
|
const formattedColumns = ref([]);
|
||||||
|
|
||||||
|
const { children, linkChildren } = useChildren(PICKER_KEY);
|
||||||
|
|
||||||
|
linkChildren();
|
||||||
|
|
||||||
const itemHeight = computed(() =>
|
const itemHeight = computed(() =>
|
||||||
props.itemHeight ? unitToPx(props.itemHeight) : DEFAULT_ITEM_HEIGHT
|
props.itemHeight ? unitToPx(props.itemHeight) : DEFAULT_ITEM_HEIGHT
|
||||||
);
|
);
|
||||||
@ -279,8 +283,6 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
provide(PICKER_KEY, { children });
|
|
||||||
|
|
||||||
watch(() => props.columns, format, { immediate: true });
|
watch(() => props.columns, format, { immediate: true });
|
||||||
|
|
||||||
useExpose({
|
useExpose({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user