Skip to content

Commit

Permalink
fix: fix previousIndex value in swiper
Browse files Browse the repository at this point in the history
  • Loading branch information
xifanTT committed Nov 30, 2024
1 parent 0f8147b commit b246809
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/swiper/demos/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
</div>
</template>
<script lang="ts" setup>
import baseDemo from './base.vue';
import custom from './custom.vue';
import fraction from './fraction.vue';
import control from './control.vue';
import card from './card.vue';
import vertical from './vertical.vue';
import outside from './outside.vue';
// import baseDemo from './base.vue';
// import custom from './custom.vue';
// import fraction from './fraction.vue';
// import control from './control.vue';
// import card from './card.vue';
// import vertical from './vertical.vue';
// import outside from './outside.vue';
import current from './current.vue';
</script>

Expand Down
3 changes: 2 additions & 1 deletion src/swiper/swiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default defineComponent({
}

swiperSource.value = source;
previousIndex.value = index;
previousIndex.value = val;
setCurrent(val);
context.emit('update:value', val);
context.emit('change', val, { source });
Expand Down Expand Up @@ -233,6 +233,7 @@ export default defineComponent({
(value, oldValue) => {
// v-model动态更新时不触发move逻辑
if (value === previousIndex.value) return;
console.log(value, previousIndex.value);
stopAutoplay();
const max = items.value.length;
const diff = (value + max - previousIndex.value) % max;
Expand Down

0 comments on commit b246809

Please sign in to comment.