# Subsection 分段器

该分段器一般用于用户从几个选项中选择某一个的场景

# 平台差异说明

App H5 微信小程序 支付宝小程序 百度小程序 头条小程序 QQ小程序

# 基本使用

  • 通过list数组参数传递分段的选项
  • 通过v-model="current"双向绑定当前激活的选项
  • list内的name属性代表显示的文本
  • list内的num属性代表文本右上方的小数字(可不填)
<template>
	<u-subsection :list="list" v-model="current"></u-subsection>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						name: '待发货',
						num: 10
					}, 
					{
						name: '待付款'
					}, 
					{
						name: '待评价',
						num: 15
					}
				],
				current: 1
			}
		}
	}
</script>

# 模式选择

通过mode设置分段器的模式

  • 值为button时为按钮类型
  • 值为subsection时为分段器形式
<u-subsection :list="list" v-model="current" mode="button"></u-subsection>

# 是否开启动画效果

animation(默认为true)设置为true的话,分段器的三种模式滑块移动时都会有动画效果

<u-subsection :animation="true"></u-subsection>

# 颜色配置

  • 通过active-color配置激活选项的文字颜色,modesubsection时无效,此时默认为白色:
  • 通过bgColor配置背景颜色
  • 通过buttonColor配置按钮颜色,modebutton时有效
<u-subsection active-color="#ff9900"></u-subsection>

# API

# Props

参数 说明 类型 默认值 可选值
list 选项的数组,形式见上方"基本使用" Array - -
v-model 双向绑定当前激活的选项 String | Number 0 -
active-color 激活时的颜色 String #303133 -
inactive-color 未激活时的颜色 String #606266 -
mode 模式选择,见上方"模式选择"说明 String button subsection
font-size 字体大小,单位rpx String | Number 28 -
height 组件高度,单位rpx String | Number 70 -
animation 是否开启动画效果,见上方说明 Boolean true false
bold 激活选项的字体是否加粗 Boolean true false
bg-color 组件背景颜色,modebutton时有效 String #eeeeef -
button-color 按钮背景颜色,modebutton时有效 String #ffffff -

# Events

事件名 说明 回调参数
change 分段器选项发生改变时触发 index:选项的index索引值,从0开始