uni-app分段器


<template>
	<view>
		<view class="uni-padding-wrap uni-common-mt">
			<!-- 
					分段器 
					导航跳转不同组件
			 -->
			<uni-segmented-control 
			:current="current" 
			<!-- 操作数组 -->
			:values="items.map(v => v.title)" 
			style-type="text" 
			:active-color="activeColor"
			@clickItem="onClickItem" />
		</view>
		<view class="content">
			<view v-if="current === 0">
				<!-- 导航组件页面 -->
				<home-recommend></home-recommend>
			</view>
			<view v-if="current === 1">
			<!-- 导航组件页面 -->
				<home-category></home-category>
			</view>
			<view v-if="current === 2">
			<!-- 导航组件页面 -->
				<home-new></home-new>
			</view>
			<view v-if="current === 3">
			<!-- 导航组件页面 -->
				<home-album></home-album>
			</view>
		</view>
	</view>
</template>

<script>
	import homeAlbum from "./home-album/home-album.vue";
	import homeRecommend from "./home-recommend/home-recommend.vue";
	import homeNew from "./home-new/home-new.vue";
	import homeCategory from "./home-category/home-category.vue";
	export default {
		components: {},
		data() {
			return {
				items: [
					{title : "推荐"},
					{title : "分类"},
					{title : "最新"},
					{title : "专辑"},
				],
				styles: [{
						value: 'button',
						text: '按钮',
						checked: true
					},
					{
						value: 'text',
						text: '文字'
					}
				],
				current: 0,
				colorIndex: 0,
				activeColor: '#d4237a',
			}
		},
		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			}
		},
		components: {
			homeAlbum,
			homeRecommend,
			homeNew,
			homeCategory
		}
	}
</script>

<style lang="scss">

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		padding: 0;
	}

	.uni-common-mt {
		margin-top: 30px;
	}

	.uni-padding-wrap {
		// width: 750rpx;
		// padding: 0px 30px;
	}

	.content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
		height: 150px;
		text-align: center;
	}

	.content-text {
		font-size: 18px;
		color: $uni-text-color;
	}

	.color-tag {
		width: 25px;
		height: 25px;
	}

	.uni-list {
		flex: 1;
	}

	.uni-list-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		background-color: #FFFFFF;
	}


	.uni-list-item__container {
		padding: 12px 15px;
		width: 100%;
		flex: 1;
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		box-sizing: border-box;
		/* #endif */
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		border-bottom-style: solid;
		border-bottom-width: 1px;
		border-bottom-color: $uni-border-color;
	}

	.uni-list-item__content-title {
		font-size: 16px;
	}
</style>


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值