Skip to content

Commit

Permalink
fix(swiper): current dynamic modification exception
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs committed Apr 2, 2024
1 parent 1c958c1 commit 72ecabf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/swiper/swiper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
defineProps,
watch,
onUnmounted,
toRefs,
} from 'vue';
import isObject from 'lodash/isObject';
import isNumber from 'lodash/isNumber';
Expand Down Expand Up @@ -95,7 +96,9 @@ const items = ref<any>([]);
const props = defineProps(SwiperProps);
const emit = defineEmits(['change', 'update:current', 'update:modelValue']);
const [current, setCurrent] = useVModel(ref(props.current), ref(props.modelValue), props.defaultCurrent);
const { current: value, modelValue } = toRefs(props);
const [current, setCurrent] = useVModel(value, modelValue, props.defaultCurrent);
const swiperContainer = ref<HTMLElement | null>(null);
const computedNavigation = computed(() => (isObject(props.navigation) ? '' : renderTNode(self, 'navigation')));
Expand Down Expand Up @@ -255,6 +258,7 @@ const updateContainerHeight = () => {
} else if (rect) {
setContainerHeight(rect.height);
}
updateItemPosition();
};
watch(current, updateContainerHeight);
Expand Down

0 comments on commit 72ecabf

Please # to comment.