| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | <template>	<swiper :circular="false" @change="onChangeTab" :current="data.current"		:style="{'height': swiperHeight + 'px'}">		<swiper-item v-for="(cItem,index) in props.list" :key="cItem">			<view class="item flex-col flex-center">				<slot :item="cItem"></slot>			</view>		</swiper-item>	</swiper></template><script setup>	import {		ref,		reactive,		watch,		onMounted	} from 'vue';	import {		onLoad,	} from "@dcloudio/uni-app";	const props = defineProps({		swiperHeight: { // swiper的高度			type: Number,			default: 0		},		positionIndex: { // 当前的数据的下标,直接定位到某条数据时使用			required: false,			type: Number,			default: 0		},		list: { // 数据数组			required: true,			type: Array,			default: []		},	})	const emits = defineEmits(['change'])	const data = reactive({		current:0,	})		watch(() => props.positionIndex, (val) => positionData(), {		immediate: true	})	watch(() => props.list, (val) => positionData(), {		immediate: true	})		function positionData() {		if (props.list[data.current]) {			props.list[data.current].mta_show = true;		}		if (props.list[data.current+1]) {			props.list[data.current+1].mta_show = true;		}		if (props.list[data.current-1]) {			props.list[data.current-1].mta_show = true;		}	}	function onChangeTab(e) {		data.current = e.detail.current;		if (props.list[data.current+1]) {			props.list[data.current+1].mta_show = true;		}		if (props.list[data.current-1]) {			props.list[data.current-1].mta_show = true;		}		emits('change', data.current)	}</script><style></style>
 |