uniapp组件-uni-segmented-control分段器

官方示例:https://ext.dcloud.net.cn/plugin?id=54 

效果图:

代码实现:

<template>
	<view>
		<view>
			<uni-segmented-control :current="current" :values="items" style-type="button" active-color="#dd524d" @clickItem="onClickItem" />
		</view>
		<view class="uni-padding-wrap uni-common-mt">
			<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#007aff" @clickItem="onClickItem" />
		</view>
		<view style="padding: 0px 30px;margin-top: 30px;">
			<uni-segmented-control :current="current" :values="items" style-type="button" active-color="#4cd964" @clickItem="onClickItem" />
		</view>
		<view>
			<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#4cd964" @clickItem="onClickItem" />
		</view>

	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				items: ['选项卡1', '选项卡2', '选项卡3'],
				current: 0,
			}
		},
		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			}
		}
	}
</script>

猜你喜欢

转载自blog.csdn.net/qq_40323256/article/details/114260031
今日推荐