Skip to content
本页导读

Swiper

组件类型:UxSwiperComponentPublicInstance

支持左右滑动堆叠效果

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
listArray数据列表

示例代码

html
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :border="false">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll :disabled="true">
			<ux-card direction="column" icon="flag-filled" title="Swiper容器" :bold="true">
				<ux-text text="支持左右滑动堆叠效果"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="Swiper" :bold="true">
				<ux-swiper :list="list">
					<template v-slot:default="{ data }">
						<view class="item" :style="{'background-color': (data as UTSJSONObject)['color']}">
							<text class="text">{{ (data as UTSJSONObject)['name'] }}</text>
						</view>
					</template>
				</ux-swiper>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
	</ux-page>
</template>
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :border="false">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll :disabled="true">
			<ux-card direction="column" icon="flag-filled" title="Swiper容器" :bold="true">
				<ux-text text="支持左右滑动堆叠效果"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="Swiper" :bold="true">
				<ux-swiper :list="list">
					<template v-slot:default="{ data }">
						<view class="item" :style="{'background-color': (data as UTSJSONObject)['color']}">
							<text class="text">{{ (data as UTSJSONObject)['name'] }}</text>
						</view>
					</template>
				</ux-swiper>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
	</ux-page>
</template>
ts
<script setup>
	import * as plus from '@/uni_modules/ux-plus'
	
	const list = ref<UTSJSONObject[]>([])
	
	const showDoc = ref(false)
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/swiper.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	const title = ref('')
	onLoad((e) => {
		title.value = e['title'] ?? ''
		
		for (var i = 0; i < 5; i++) {
			list.value.push({
				name: `${i + 1}`,
				color: i % 2 == 0 ? '#D6D6D6' : '#E6E6E6'
			} as UTSJSONObject)
		}
	})
</script>
<script setup>
	import * as plus from '@/uni_modules/ux-plus'
	
	const list = ref<UTSJSONObject[]>([])
	
	const showDoc = ref(false)
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/swiper.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	const title = ref('')
	onLoad((e) => {
		title.value = e['title'] ?? ''
		
		for (var i = 0; i < 5; i++) {
			list.value.push({
				name: `${i + 1}`,
				color: i % 2 == 0 ? '#D6D6D6' : '#E6E6E6'
			} as UTSJSONObject)
		}
	})
</script>
css
<style lang="scss">
	.item {
		flex: 1;
		background-color: #f0f0f0;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		
		.text {
			font-size: 18px;
		}
	}
</style>
<style lang="scss">
	.item {
		flex: 1;
		background-color: #f0f0f0;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		
		.text {
			font-size: 18px;
		}
	}
</style>