wangxy 6 månader sedan
förälder
incheckning
55b72fbdbd
1 ändrade filer med 12 tillägg och 3 borttagningar
  1. 12 3
      components/wSwiper/wSwiper.vue

+ 12 - 3
components/wSwiper/wSwiper.vue

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