mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +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
|
||||
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;
|
||||
|
||||
@ -278,7 +279,8 @@ export default createComponent({
|
||||
|
||||
setIndex(state.index);
|
||||
|
||||
useParent(PICKER_KEY, {
|
||||
useParent(PICKER_KEY);
|
||||
useExpose({
|
||||
state,
|
||||
setIndex,
|
||||
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';
|
||||
|
||||
// Utils
|
||||
@ -9,6 +9,7 @@ import { unitToPx } from '../utils/format/unit';
|
||||
|
||||
// Composition
|
||||
import { useExpose } from '../composition/use-expose';
|
||||
import { useChildren } from '../composition/use-relation';
|
||||
|
||||
// Components
|
||||
import Loading from '../loading';
|
||||
@ -40,9 +41,12 @@ export default createComponent({
|
||||
emits: ['confirm', 'cancel', 'change'],
|
||||
|
||||
setup(props, { emit, slots }) {
|
||||
const children = reactive([]);
|
||||
const formattedColumns = ref([]);
|
||||
|
||||
const { children, linkChildren } = useChildren(PICKER_KEY);
|
||||
|
||||
linkChildren();
|
||||
|
||||
const itemHeight = computed(() =>
|
||||
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 });
|
||||
|
||||
useExpose({
|
||||
|
Loading…
x
Reference in New Issue
Block a user