chore: optional chaining (#8283)

This commit is contained in:
neverland
2021-03-05 11:05:27 +08:00
committed by GitHub
parent 391ccd4240
commit 09e1eb5a0d
7 changed files with 24 additions and 47 deletions
+5 -11
View File
@@ -29,7 +29,7 @@ import ImagePreviewItem from './ImagePreviewItem';
const [createComponent, bem] = createNamespace('image-preview');
export type ImagePreviewScaleEventParams = {
export type ScaleEventParams = {
scale: number;
index: number;
};
@@ -110,8 +110,7 @@ export default createComponent({
}
};
const emitScale = (args: ImagePreviewScaleEventParams) =>
emit('scale', args);
const emitScale = (args: ScaleEventParams) => emit('scale', args);
const updateShow = (show: boolean) => emit('update:show', show);
@@ -191,11 +190,8 @@ export default createComponent({
const onClosed = () => emit('closed');
const swipeTo = (index: number, options?: SwipeToOptions) => {
if (swipeRef.value) {
swipeRef.value.swipeTo(index, options);
}
};
const swipeTo = (index: number, options?: SwipeToOptions) =>
swipeRef.value?.swipeTo(index, options);
useExpose({ swipeTo });
@@ -205,9 +201,7 @@ export default createComponent({
watch(
() => props.startPosition,
(value) => {
setActive(+value);
}
(value) => setActive(+value)
);
watch(