uni-app|tabs滑动|uView 1.X|u-tabs-swiper全屏选项卡|案例

 template
<template>
	<view class="mainCont">
		<view class="wrap">
			<view class="u-tabs-box">
				<u-tabs-swiper 
					bgColor=" #F5F5F5" 
					activeColor="#FF3229" 
					ref="tabs"
					:list="list"
					:current="current"
					@change="change"
					:is-scroll="false"
					swiperWidth="750"
					font-size="30rpx"
					barWidth="71"
					barHeight="6"
				></u-tabs-swiper>
			</view>
			<swiper class="swiper-box" :current="swiperCurrent"                     
                @transition="transition" 
                @animationfinish="animationfinish">

			    <swiper-item class="swiper-item">
					<scroll-view scroll-y 
                        style="height: 100%;width: 100%;" 
                        @scrolltolower="reachBottom">
					    <view class="page-box">
						
                        <!--自定义内容-->                        
	
						</view>
					</scroll-view>
				</swiper-item>

				<swiper-item class="swiper-item">
					<scroll-view scroll-y 
                        style="height: 100%;width: 100%;" 
                        @scrolltolower="reachBottom">
					    <view class="page-box">
						
                        <!--自定义内容-->                        
	
						</view>
					</scroll-view>
				</swiper-item>
    
                <swiper-item class="swiper-item">
					<scroll-view scroll-y 
                        style="height: 100%;width: 100%;" 
                        @scrolltolower="reachBottom">
					    <view class="page-box">
						
                        <!--自定义内容-->                        
	
						</view>
					</scroll-view>
				</swiper-item>

                <swiper-item class="swiper-item">
					<scroll-view scroll-y 
                        style="height: 100%;width: 100%;" 
                        @scrolltolower="reachBottom">
					    <view class="page-box">
						
                        <!--自定义内容-->                        
	
						</view>
					</scroll-view>
				</swiper-item>

			</swiper>

            <view class="page-footer">
			    <view class="contract-button">
			    	<!-- 自定义底部栏(可选) -->
			    </view>
			</view>            

		</view>
	</view>
</template>
script
<script>
export default {
	data() {
		return {
			list: [
				{
					name: 'title-1'
				},
				{
					name: 'title-2'
				},
				{
					name: 'title-3'
				},
				{
					name: 'title-4',
				}
			],
			current: 0,
			swiperCurrent: 0,
			tabsHeight: 0,
			dx: 0,
		};
	},
	onLoad() {

	},
	computed: {

	},
	methods: {
		// tab栏切换
		change(index) {
			this.swiperCurrent = index;
		},
		transition({ detail: { dx } }) {
			this.$refs.tabs.setDx(dx);
		},
		animationfinish({ detail: { current } }) {
			this.$refs.tabs.setFinishCurrent(current);
			this.swiperCurrent = current;
			this.current = current;
		}
	}
};
</script>
 style
<style scoped lang="scss">
/* #ifndef H5 */
page {
	height: 100%;
	background-color: #f2f2f2;
}
/* #endif */
</style>

<style lang="scss" scoped>
.mainCont {
	background: #F5F5F5;
}

// tabs framework config
.u-tabs-box {
	margin-bottom: 24rpx;
}

.page-box {
	width: 686rpx;
	background-color: #FFFFFF;
	border-radius: 12rpx;
	margin-left: 32rpx;
}

.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}

.swiper-box {
	flex: 1;
}

.swiper-item {
	height: 100%;
}

// footer config
.page-footer {
	width: 750rpx;
	height: 128rpx;
	background: #FFFFFF;
	box-shadow: 0rpx -4rpx 16rpx rgba(219,208,208,0.61);
	opacity: 1;
	border-radius: 0rpx;
	
	.contract-button {
		width: 686rpx;
		height: 80rpx;
		
		margin-top: 24rpx;
		margin-left: 32rpx;
		
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: 500;
		
		text-align: center;
		
		line-height: 80rpx;
		color: #FFFFFF;
		letter-spacing: 5rpx;
		
		background: linear-gradient(137deg, #FF3229 0%, #FF7B59 100%);
		opacity: 1;
		border-radius: 40rpx;
	}
	
}
</style>
官方文档

uView 1.X tabs-swipe 组件

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值