chore: rename variables and comments

This commit is contained in:
chenjiahan 2021-03-02 17:55:22 +08:00
parent a0addef294
commit 6e5329cbe0
50 changed files with 85 additions and 82 deletions

View File

@ -2,7 +2,7 @@ import { computed, PropType } from 'vue';
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { ACTION_BAR_KEY } from '../action-bar'; import { ACTION_BAR_KEY } from '../action-bar';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { useRoute, routeProps } from '../composables/use-route'; import { useRoute, routeProps } from '../composables/use-route';

View File

@ -1,7 +1,7 @@
import { createNamespace, UnknownProp } from '../utils'; import { createNamespace, UnknownProp } from '../utils';
import { ACTION_BAR_KEY } from '../action-bar'; import { ACTION_BAR_KEY } from '../action-bar';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useRoute, routeProps } from '../composables/use-route'; import { useRoute, routeProps } from '../composables/use-route';

View File

@ -51,10 +51,10 @@ export default createComponent({
emits: ['select', 'cancel', 'update:show'], emits: ['select', 'cancel', 'update:show'],
setup(props, { slots, emit }) { setup(props, { slots, emit }) {
const onUpdateShow = (show: boolean) => emit('update:show', show); const updateShow = (show: boolean) => emit('update:show', show);
const onCancel = () => { const onCancel = () => {
onUpdateShow(false); updateShow(false);
emit('cancel'); emit('cancel');
}; };
@ -118,7 +118,7 @@ export default createComponent({
emit('select', item, index); emit('select', item, index);
if (props.closeOnClickAction) { if (props.closeOnClickAction) {
onUpdateShow(false); updateShow(false);
} }
}; };
@ -157,7 +157,7 @@ export default createComponent({
safeAreaInsetBottom={props.safeAreaInsetBottom} safeAreaInsetBottom={props.safeAreaInsetBottom}
{...{ {...{
...pick(props, popupSharedPropKeys), ...pick(props, popupSharedPropKeys),
'onUpdate:show': onUpdateShow, 'onUpdate:show': updateShow,
}} }}
> >
{renderHeader()} {renderHeader()}

View File

@ -4,7 +4,7 @@ import { ref, watch, computed, nextTick, reactive, PropType } from 'vue';
import { ComponentInstance, createNamespace, isObject } from '../utils'; import { ComponentInstance, createNamespace, isObject } from '../utils';
import { isMobile } from '../utils/validate/mobile'; import { isMobile } from '../utils/validate/mobile';
// Composition // Composables
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
// Components // Components

View File

@ -13,7 +13,7 @@ import {
import { deepClone } from '../utils/deep-clone'; import { deepClone } from '../utils/deep-clone';
import { pick, createNamespace, ComponentInstance } from '../utils'; import { pick, createNamespace, ComponentInstance } from '../utils';
// Composition // Composables
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
// Components // Components

View File

@ -12,7 +12,7 @@ import {
formatMonthTitle, formatMonthTitle,
} from '../utils'; } from '../utils';
// Composition // Composables
import { useToggle } from '@vant/use'; import { useToggle } from '@vant/use';
import { useExpose } from '../../composables/use-expose'; import { useExpose } from '../../composables/use-expose';
import { useHeight } from '../../composables/use-height'; import { useHeight } from '../../composables/use-height';

View File

@ -17,7 +17,7 @@ import {
getDayByOffset, getDayByOffset,
} from './utils'; } from './utils';
// Composition // Composables
import { raf, useRect, onMountedOrActivated } from '@vant/use'; import { raf, useRect, onMountedOrActivated } from '@vant/use';
import { useRefs } from '../composables/use-refs'; import { useRefs } from '../composables/use-refs';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
@ -424,7 +424,7 @@ export default createComponent({
} }
}; };
const togglePopup = (value: boolean) => emit('update:show', value); const updateShow = (value: boolean) => emit('update:show', value);
const renderMonth = (date: Date, index: number) => { const renderMonth = (date: Date, index: number) => {
const showMonthTitle = index !== 0 || !props.showSubtitle; const showMonthTitle = index !== 0 || !props.showSubtitle;
@ -533,7 +533,7 @@ export default createComponent({
teleport={props.teleport} teleport={props.teleport}
closeOnPopstate={props.closeOnPopstate} closeOnPopstate={props.closeOnPopstate}
closeOnClickOverlay={props.closeOnClickOverlay} closeOnClickOverlay={props.closeOnClickOverlay}
{...{ 'onUpdate:show': togglePopup }} {...{ 'onUpdate:show': updateShow }}
> >
{renderCalendar()} {renderCalendar()}
</Popup> </Popup>

View File

@ -3,7 +3,7 @@ import { PropType, CSSProperties } from 'vue';
// Utils // Utils
import { createNamespace, isDef, UnknownProp } from '../utils'; import { createNamespace, isDef, UnknownProp } from '../utils';
// Composition // Composables
import { useRoute, routeProps } from '../composables/use-route'; import { useRoute, routeProps } from '../composables/use-route';
// Components // Components

View File

@ -21,7 +21,7 @@ export type CheckboxGroupProvide = CheckerParent & {
max: number | string; max: number | string;
modelValue: unknown[]; modelValue: unknown[];
}; };
updateModelValue: (value: unknown[]) => void; updateValue: (value: unknown[]) => void;
}; };
export default createComponent({ export default createComponent({
@ -42,9 +42,7 @@ export default createComponent({
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const { children, linkChildren } = useChildren(CHECKBOX_GROUP_KEY); const { children, linkChildren } = useChildren(CHECKBOX_GROUP_KEY);
const updateModelValue = (value: unknown[]) => { const updateValue = (value: unknown[]) => emit('update:modelValue', value);
emit('update:modelValue', value);
};
const toggleAll = (options: CheckboxGroupToggleAllOptions = {}) => { const toggleAll = (options: CheckboxGroupToggleAllOptions = {}) => {
if (typeof options === 'boolean') { if (typeof options === 'boolean') {
@ -64,7 +62,7 @@ export default createComponent({
}); });
const names = checkedChildren.map((item: any) => item.name); const names = checkedChildren.map((item: any) => item.name);
updateModelValue(names); updateValue(names);
}; };
watch( watch(
@ -76,7 +74,7 @@ export default createComponent({
useLinkField(() => props.modelValue); useLinkField(() => props.modelValue);
linkChildren({ linkChildren({
props, props,
updateModelValue, updateValue,
}); });
return () => <div class={bem([props.direction])}>{slots.default?.()}</div>; return () => <div class={bem([props.direction])}>{slots.default?.()}</div>;

View File

@ -1,10 +1,16 @@
import { computed, watch } from 'vue'; import { computed, watch } from 'vue';
// Utils
import { createNamespace, pick } from '../utils'; import { createNamespace, pick } from '../utils';
import { CHECKBOX_GROUP_KEY, CheckboxGroupProvide } from '../checkbox-group';
// Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';
// Components
import Checker, { checkerProps } from './Checker'; import Checker, { checkerProps } from './Checker';
import { CHECKBOX_GROUP_KEY, CheckboxGroupProvide } from '../checkbox-group';
const [createComponent, bem] = createNamespace('checkbox'); const [createComponent, bem] = createNamespace('checkbox');
@ -34,7 +40,7 @@ export default createComponent({
value.push(name); value.push(name);
if (props.bindGroup) { if (props.bindGroup) {
parent!.updateModelValue(value); parent!.updateValue(value);
} }
} }
} else { } else {
@ -44,7 +50,7 @@ export default createComponent({
value.splice(index, 1); value.splice(index, 1);
if (props.bindGroup) { if (props.bindGroup) {
parent!.updateModelValue(value); parent!.updateValue(value);
} }
} }
} }

View File

@ -3,7 +3,7 @@ import { ref, watch, computed, nextTick } from 'vue';
// Utils // Utils
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
// Composition // Composables
import { raf, doubleRaf, useParent } from '@vant/use'; import { raf, doubleRaf, useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { useLazyRender } from '../composables/use-lazy-render'; import { useLazyRender } from '../composables/use-lazy-render';

View File

@ -4,7 +4,7 @@ import { watch, computed } from 'vue';
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { parseFormat } from './utils'; import { parseFormat } from './utils';
// Composition // Composables
import { useCountDown } from '@vant/use'; import { useCountDown } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -3,7 +3,7 @@ import { watch, computed, nextTick, reactive, PropType, onMounted } from 'vue';
// Utils // Utils
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
// Composition // Composables
import { useWindowSize } from '@vant/use'; import { useWindowSize } from '@vant/use';
import { useRefs } from '../composables/use-refs'; import { useRefs } from '../composables/use-refs';

View File

@ -19,7 +19,7 @@ import {
DatetimePickerType, DatetimePickerType,
} from './utils'; } from './utils';
// Composition // Composables
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
// Components // Components

View File

@ -10,7 +10,7 @@ import {
} from '../utils'; } from '../utils';
import { times, sharedProps, pickerKeys } from './utils'; import { times, sharedProps, pickerKeys } from './utils';
// Composition // Composables
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
// Components // Components

View File

@ -64,10 +64,10 @@ export default createComponent({
cancel: false, cancel: false,
}); });
const onUpdateShow = (value: boolean) => emit('update:show', value); const updateShow = (value: boolean) => emit('update:show', value);
const close = (action: DialogAction) => { const close = (action: DialogAction) => {
onUpdateShow(false); updateShow(false);
if (props.callback) { if (props.callback) {
props.callback(action); props.callback(action);
} }
@ -212,7 +212,7 @@ export default createComponent({
aria-labelledby={title || message} aria-labelledby={title || message}
{...{ {...{
...pick(props, popupKeys), ...pick(props, popupKeys),
'onUpdate:show': onUpdateShow, 'onUpdate:show': updateShow,
}} }}
> >
{renderTitle()} {renderTitle()}

View File

@ -10,7 +10,7 @@ import {
import { createNamespace, UnknownProp } from '../utils'; import { createNamespace, UnknownProp } from '../utils';
import { DROPDOWN_KEY, DropdownMenuProvide } from '../dropdown-menu'; import { DROPDOWN_KEY, DropdownMenuProvide } from '../dropdown-menu';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -3,7 +3,7 @@ import { ref, computed, PropType, CSSProperties, Ref } from 'vue';
// Utils // Utils
import { isDef, ComponentInstance, createNamespace } from '../utils'; import { isDef, ComponentInstance, createNamespace } from '../utils';
// Composition // Composables
import { import {
useRect, useRect,
useChildren, useChildren,

View File

@ -26,7 +26,7 @@ import {
} from '../utils'; } from '../utils';
import { runSyncRule } from './utils'; import { runSyncRule } from './utils';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { FORM_KEY, FIELD_KEY } from '../composables/use-link-field'; import { FORM_KEY, FIELD_KEY } from '../composables/use-link-field';

View File

@ -3,7 +3,7 @@ import { PropType } from 'vue';
// Utils // Utils
import { createNamespace, ComponentInstance } from '../utils'; import { createNamespace, ComponentInstance } from '../utils';
// Composition // Composables
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
import { FORM_KEY } from '../composables/use-link-field'; import { FORM_KEY } from '../composables/use-link-field';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -5,7 +5,7 @@ import { createNamespace, addUnit } from '../utils';
import { BORDER } from '../utils/constant'; import { BORDER } from '../utils/constant';
import { GRID_KEY, GridProvide } from '../grid'; import { GRID_KEY, GridProvide } from '../grid';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useRoute, routeProps } from '../composables/use-route'; import { useRoute, routeProps } from '../composables/use-route';

View File

@ -1,10 +1,10 @@
import { nextTick, onMounted, PropType, reactive, ref, watch } from 'vue'; import { ref, watch, nextTick, onMounted, PropType, reactive } from 'vue';
// Utils // Utils
import { ComponentInstance, UnknownProp, createNamespace } from '../utils'; import { ComponentInstance, UnknownProp, createNamespace } from '../utils';
import { callInterceptor, Interceptor } from '../utils/interceptor'; import { callInterceptor, Interceptor } from '../utils/interceptor';
// Composition // Composables
import { useWindowSize } from '@vant/use'; import { useWindowSize } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
@ -98,13 +98,13 @@ export default createComponent({
const emitScale = (args: ImagePreviewScaleEventParams) => const emitScale = (args: ImagePreviewScaleEventParams) =>
emit('scale', args); emit('scale', args);
const toggle = (show: boolean) => emit('update:show', show); const updateShow = (show: boolean) => emit('update:show', show);
const emitClose = () => { const emitClose = () => {
callInterceptor({ callInterceptor({
interceptor: props.beforeClose, interceptor: props.beforeClose,
args: [state.active], args: [state.active],
done: () => toggle(false), done: () => updateShow(false),
}); });
}; };
@ -221,7 +221,7 @@ export default createComponent({
overlayClass={bem('overlay')} overlayClass={bem('overlay')}
closeOnPopstate={props.closeOnPopstate} closeOnPopstate={props.closeOnPopstate}
onClosed={onClosed} onClosed={onClosed}
{...{ 'onUpdate:show': toggle }} {...{ 'onUpdate:show': updateShow }}
> >
{renderClose()} {renderClose()}
{renderImages()} {renderImages()}

View File

@ -3,7 +3,7 @@ import { watch, computed, reactive, CSSProperties, defineComponent } from 'vue';
// Utils // Utils
import { range, preventDefault, createNamespace } from '../utils'; import { range, preventDefault, createNamespace } from '../utils';
// Composition // Composables
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';
// Component // Component

View File

@ -6,7 +6,7 @@ import { BORDER_BOTTOM } from '../utils/constant';
import { INDEX_BAR_KEY, IndexBarProvide } from '../index-bar'; import { INDEX_BAR_KEY, IndexBarProvide } from '../index-bar';
import { getScrollTop, getRootScrollTop } from '../utils/dom/scroll'; import { getScrollTop, getRootScrollTop } from '../utils/dom/scroll';
// Composition // Composables
import { useRect, useParent } from '@vant/use'; import { useRect, useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -20,7 +20,7 @@ import {
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
// Composition // Composables
import { import {
useRect, useRect,
useChildren, useChildren,

View File

@ -3,7 +3,7 @@ import { ref, watch, nextTick, onUpdated, onMounted, PropType } from 'vue';
// Utils // Utils
import { isHidden, createNamespace } from '../utils'; import { isHidden, createNamespace } from '../utils';
// Composition // Composables
import { useRect, useScrollParent, useEventListener } from '@vant/use'; import { useRect, useScrollParent, useEventListener } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -4,7 +4,7 @@ import { ref, CSSProperties } from 'vue';
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BORDER_BOTTOM } from '../utils/constant'; import { BORDER_BOTTOM } from '../utils/constant';
// Composition // Composables
import { usePlaceholder } from '../composables/use-placeholder'; import { usePlaceholder } from '../composables/use-placeholder';
// Components // Components

View File

@ -1,7 +1,7 @@
import { ref, watch, reactive, PropType } from 'vue'; import { ref, watch, reactive, PropType } from 'vue';
import { isDef, createNamespace } from '../utils'; import { isDef, createNamespace } from '../utils';
// Composition // Composables
import { import {
raf, raf,
useRect, useRect,

View File

@ -11,7 +11,7 @@ import {
createNamespace, createNamespace,
} from '../utils'; } from '../utils';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -9,7 +9,7 @@ import {
} from '../utils'; } from '../utils';
import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant'; import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant';
// Composition // Composables
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -13,7 +13,7 @@ import { Instance, createPopper, offsetModifier } from '@vant/popperjs';
import { ComponentInstance, createNamespace } from '../utils'; import { ComponentInstance, createNamespace } from '../utils';
import { BORDER_BOTTOM } from '../utils/constant'; import { BORDER_BOTTOM } from '../utils/constant';
// Composition // Composables
import { useClickAway } from '@vant/use'; import { useClickAway } from '@vant/use';
// Components // Components
@ -125,11 +125,11 @@ export default createComponent({
}); });
}; };
const toggle = (value: boolean) => emit('update:show', value); const updateShow = (value: boolean) => emit('update:show', value);
const onClickWrapper = () => { const onClickWrapper = () => {
if (props.trigger === 'click') { if (props.trigger === 'click') {
toggle(!props.show); updateShow(!props.show);
} }
}; };
@ -146,11 +146,11 @@ export default createComponent({
emit('select', action, index); emit('select', action, index);
if (props.closeOnClickAction) { if (props.closeOnClickAction) {
toggle(false); updateShow(false);
} }
}; };
const onClickAway = () => toggle(false); const onClickAway = () => updateShow(false);
const renderAction = (action: PopoverAction, index: number) => { const renderAction = (action: PopoverAction, index: number) => {
const { icon, text, color, disabled, className } = action; const { icon, text, color, disabled, className } = action;
@ -194,7 +194,7 @@ export default createComponent({
transition="van-popover-zoom" transition="van-popover-zoom"
lockScroll={false} lockScroll={false}
onTouchstart={onTouchstart} onTouchstart={onTouchstart}
{...{ ...attrs, 'onUpdate:show': toggle }} {...{ ...attrs, 'onUpdate:show': updateShow }}
> >
<div class={bem('arrow')} /> <div class={bem('arrow')} />
<div role="menu" class={bem('content')}> <div role="menu" class={bem('content')}>

View File

@ -15,7 +15,7 @@ import {
import { popupSharedProps } from './shared'; import { popupSharedProps } from './shared';
import { createNamespace, isDef } from '../utils'; import { createNamespace, isDef } from '../utils';
// Composition // Composables
import { useEventListener } from '@vant/use'; import { useEventListener } from '@vant/use';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { useLockScroll } from '../composables/use-lock-scroll'; import { useLockScroll } from '../composables/use-lock-scroll';

View File

@ -3,7 +3,7 @@ import { ref, watch, reactive, nextTick } from 'vue';
// Utils // Utils
import { preventDefault, getScrollTop, createNamespace } from '../utils'; import { preventDefault, getScrollTop, createNamespace } from '../utils';
// Composition // Composables
import { useScrollParent } from '@vant/use'; import { useScrollParent } from '@vant/use';
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';

View File

@ -12,7 +12,7 @@ export type RadioGroupProvide = CheckerParent & {
props: { props: {
modelValue: unknown; modelValue: unknown;
}; };
updateModelValue: (value: unknown) => void; updateValue: (value: unknown) => void;
}; };
export default createComponent({ export default createComponent({
@ -29,8 +29,7 @@ export default createComponent({
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const { linkChildren } = useChildren(RADIO_KEY); const { linkChildren } = useChildren(RADIO_KEY);
const updateModelValue = (value: unknown) => const updateValue = (value: unknown) => emit('update:modelValue', value);
emit('update:modelValue', value);
watch( watch(
() => props.modelValue, () => props.modelValue,
@ -39,7 +38,7 @@ export default createComponent({
linkChildren({ linkChildren({
props, props,
updateModelValue, updateValue,
}); });
useLinkField(() => props.modelValue); useLinkField(() => props.modelValue);

View File

@ -20,7 +20,7 @@ export default createComponent({
const toggle = () => { const toggle = () => {
if (parent) { if (parent) {
parent.updateModelValue(props.name); parent.updateValue(props.name);
} else { } else {
emit('update:modelValue', props.name); emit('update:modelValue', props.name);
} }

View File

@ -3,7 +3,7 @@ import { computed } from 'vue';
// Utils // Utils
import { addUnit, createNamespace, preventDefault } from '../utils'; import { addUnit, createNamespace, preventDefault } from '../utils';
// Composition // Composables
import { useRefs } from '../composables/use-refs'; import { useRefs } from '../composables/use-refs';
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';

View File

@ -8,7 +8,7 @@ import {
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
// Composition // Composables
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
// Components // Components

View File

@ -65,10 +65,10 @@ export default createComponent({
emits: ['cancel', 'select', 'update:show'], emits: ['cancel', 'select', 'update:show'],
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const toggle = (value: boolean) => emit('update:show', value); const updateShow = (value: boolean) => emit('update:show', value);
const onCancel = () => { const onCancel = () => {
toggle(false); updateShow(false);
emit('cancel'); emit('cancel');
}; };
@ -143,7 +143,7 @@ export default createComponent({
position="bottom" position="bottom"
{...{ {...{
...pick(props, popupKeys), ...pick(props, popupKeys),
'onUpdate:show': toggle, 'onUpdate:show': updateShow,
}} }}
> >
{renderHeader()} {renderHeader()}

View File

@ -9,7 +9,7 @@ import {
createNamespace, createNamespace,
} from '../utils'; } from '../utils';
// Composition // Composables
import { useRect } from '@vant/use'; import { useRect } from '@vant/use';
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';

View File

@ -5,7 +5,7 @@ import { createNamespace } from '../utils';
import { BORDER } from '../utils/constant'; import { BORDER } from '../utils/constant';
import { STEPS_KEY, StepsProvide } from '../steps'; import { STEPS_KEY, StepsProvide } from '../steps';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
// Components // Components

View File

@ -12,7 +12,7 @@ import {
createNamespace, createNamespace,
} from '../utils'; } from '../utils';
// Composition // Composables
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';
import { Interceptor, callInterceptor } from '../utils/interceptor'; import { Interceptor, callInterceptor } from '../utils/interceptor';

View File

@ -3,7 +3,7 @@ import { computed, CSSProperties, PropType, reactive, ref } from 'vue';
// Utils // Utils
import { createNamespace, getScrollTop, isHidden, unitToPx } from '../utils'; import { createNamespace, getScrollTop, isHidden, unitToPx } from '../utils';
// Composition // Composables
import { useRect, useEventListener, useScrollParent } from '@vant/use'; import { useRect, useEventListener, useScrollParent } from '@vant/use';
import { useVisibilityChange } from '../composables/use-visibility-change'; import { useVisibilityChange } from '../composables/use-visibility-change';

View File

@ -4,7 +4,7 @@ import { ref, Ref, reactive, computed, PropType } from 'vue';
import { range, isDef, createNamespace, preventDefault } from '../utils'; import { range, isDef, createNamespace, preventDefault } from '../utils';
import { callInterceptor, Interceptor } from '../utils/interceptor'; import { callInterceptor, Interceptor } from '../utils/interceptor';
// Composition // Composables
import { useRect, useClickAway } from '@vant/use'; import { useRect, useClickAway } from '@vant/use';
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';

View File

@ -20,7 +20,7 @@ import {
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
// Composition // Composables
import { import {
useRect, useRect,
doubleRaf, doubleRaf,

View File

@ -2,7 +2,7 @@ import { ref, watch, nextTick, PropType, CSSProperties } from 'vue';
import { createNamespace, UnknownProp } from '../utils'; import { createNamespace, UnknownProp } from '../utils';
import { TABS_KEY, TabsProvide } from '../tabs'; import { TABS_KEY, TabsProvide } from '../tabs';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { routeProps } from '../composables/use-route'; import { routeProps } from '../composables/use-route';

View File

@ -4,7 +4,7 @@ import { TABBAR_KEY, TabbarProvide } from '../tabbar';
// Utils // Utils
import { createNamespace, isObject } from '../utils'; import { createNamespace, isObject } from '../utils';
// Composition // Composables
import { useParent } from '@vant/use'; import { useParent } from '@vant/use';
import { routeProps, useRoute } from '../composables/use-route'; import { routeProps, useRoute } from '../composables/use-route';

View File

@ -5,7 +5,7 @@ import { createNamespace } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { callInterceptor, Interceptor } from '../utils/interceptor'; import { callInterceptor, Interceptor } from '../utils/interceptor';
// Composition // Composables
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
import { usePlaceholder } from '../composables/use-placeholder'; import { usePlaceholder } from '../composables/use-placeholder';

View File

@ -28,7 +28,7 @@ import { scrollLeftTo, scrollTopTo } from './utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { callInterceptor, Interceptor } from '../utils/interceptor'; import { callInterceptor, Interceptor } from '../utils/interceptor';
// Composition // Composables
import { import {
useChildren, useChildren,
useWindowSize, useWindowSize,

View File

@ -60,9 +60,11 @@ export default createComponent({
} }
}; };
const updateShow = (show: boolean) => emit('update:show', show);
const onClick = () => { const onClick = () => {
if (props.closeOnClick) { if (props.closeOnClick) {
emit('update:show', false); updateShow(false);
} }
}; };
@ -70,8 +72,6 @@ export default createComponent({
clearTimeout(timer); clearTimeout(timer);
}; };
const toggle = (show: boolean) => emit('update:show', show);
const renderIcon = () => { const renderIcon = () => {
const { icon, type, iconPrefix, loadingType } = props; const { icon, type, iconPrefix, loadingType } = props;
const hasIcon = icon || type === 'success' || type === 'fail'; const hasIcon = icon || type === 'success' || type === 'fail';
@ -109,7 +109,7 @@ export default createComponent({
clearTimer(); clearTimer();
if (props.show && props.duration > 0) { if (props.show && props.duration > 0) {
timer = setTimeout(() => { timer = setTimeout(() => {
emit('update:show', false); updateShow(false);
}, props.duration); }, props.duration);
} }
}); });
@ -132,7 +132,7 @@ export default createComponent({
closeOnClickOverlay={props.closeOnClickOverlay} closeOnClickOverlay={props.closeOnClickOverlay}
onClick={onClick} onClick={onClick}
onClosed={clearTimer} onClosed={clearTimer}
{...{ 'onUpdate:show': toggle }} {...{ 'onUpdate:show': updateShow }}
> >
{renderIcon()} {renderIcon()}
{renderMessage()} {renderMessage()}

View File

@ -14,7 +14,7 @@ import {
UploaderResultType, UploaderResultType,
} from './utils'; } from './utils';
// Composition // Composables
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';