Jelajahi Sumber

Merge branch '2024鹅状元' of https://gogs.mtavip.com/wangguoyu/uniProject into 2024鹅状元

tanxue 6 bulan lalu
induk
melakukan
8a455f32ea
1 mengubah file dengan 12 tambahan dan 3 penghapusan
  1. 12 3
      components/wSwiper/wSwiper.vue

+ 12 - 3
components/wSwiper/wSwiper.vue

@@ -1,5 +1,5 @@
 <template>
-	<swiper :circular="false" @change="onChangeTab" :current="data.current"
+	<swiper :circular="false" @change="onChangeTab" :current="data.current" :duration="data.duration"
 		:style="{'height': swiperHeight + 'px'}">
 		<swiper-item v-for="(cItem,index) in props.list" :key="cItem">
 			<view class="item flex-col flex-center">
@@ -14,7 +14,8 @@
 		ref,
 		reactive,
 		watch,
-		onMounted
+		onMounted,
+		nextTick
 	} from 'vue';
 	import {
 		onLoad,
@@ -39,9 +40,14 @@
 	const emits = defineEmits(['change'])
 	const data = reactive({
 		current:0,
+		duration: 500
 	})
 	
-	watch(() => props.positionIndex, (val) => positionData(), {
+	watch(() => props.positionIndex, (val) => {
+		data.duration = 0
+		data.current = props.positionIndex
+		positionData()
+	}, {
 		immediate: true
 	})
 	watch(() => props.list, (val) => positionData(), {
@@ -59,6 +65,9 @@
 		if (props.list[data.current-1]) {
 			props.list[data.current-1].mta_show = true;
 		}
+		nextTick(() => {
+			data.duration = 500;
+		})
 	}
 	function onChangeTab(e) {
 		data.current = e.detail.current;