微信小程序扩展组件·纵向选项卡组件
微信小程序作为一款轻量级的应用,其功能丰富且易于开发,在微信小程序中,我们可以使用各种扩展组件来丰富应用的功能,本文将介绍一种常用的扩展组件——纵向选项卡组件。
纵向选项卡组件简介
纵向选项卡组件是一种常见的UI组件,它可以在一个页面中展示多个选项,用户可以通过点击不同的选项切换到不同的页面或内容,这种组件通常用于展示多个相关的内容,方便用户快速浏览和选择。
纵向选项卡组件的使用方法
1、在小程序的app.json文件中,添加"usingComponents"字段,声明要使用的纵向选项卡组件:
{ "usingComponents": { "vantabs": "path/to/vantweapp/dist/tabs/index" } }2、在需要使用纵向选项卡组件的页面的json文件中,引入组件:
{ "usingComponents": { "vantab": "path/to/vantweapp/dist/tabs/index" } }3、在页面的wxml文件中,添加纵向选项卡组件:
<vantabs> <vantab title="标签1">内容1</vantab> <vantab title="标签2">内容2</vantab> <vantab title="标签3">内容3</vantab> </vantabs>纵向选项卡组件的属性和方法
1、属性:
属性名 | 类型 | 默认值 | 说明 |
active | Number | 0 | 当前激活的标签索引,从0开始 |
animated | Boolean | true | 是否开启动画效果 |
duration | Number | 300 | 动画时长,单位为毫秒 |
color | String | #999999 | 标题颜色 |
fontSize | Number | 14 | 标题字体大小 |
backgroundColor | String | #ffffff | 背景颜色 |
borderStyle | String | solid | 边框样式 |
borderColor | String | #eeeeee | 边框颜色 |
lineHeight | Number | 50 | 行高,单位为rpx |
radius | Number | 8 | 圆角大小,单位为rpx |
scrollable | Boolean | false | 是否开启滚动条 |
lazyLoad | Boolean | false | 是否开启懒加载 |
showIndicator | Boolean | true | 是否显示指示器 |
leftIconColor | String | #999999 | 左侧图标颜色(仅适用于自定义图标) |
rightIconColor | String | #999999 | 右侧图标颜色(仅适用于自定义图标) |
fixedColor | String | #1aad19 | 固定态的颜色(仅适用于自定义图标) |
activeColor | String | #1aad19 | 激活态的颜色(仅适用于自定义图标) |
disabledColor | String | #cccccc | 禁用态的颜色(仅适用于自定义图标) |
fontWeight | String | normal | 标题字体粗细,可选值为normal、bold、bolder、lighter、100、200、300、400、500、600、700、800、900、inherit等 |
fontStyle | String | normal | 标题字体样式,可选值为normal、italic、oblique等 |
textAlign | String | center | 标题对齐方式,可选值为left、center、right等 |
| customIconsLeft / customIconsRight / customIconsTop / customIconsBottom / customIconsInactiveText / customIconsActiveText / customIconsInactiveColor / customIconsActiveColor / customIconsInactiveSize / customIconsActiveSize / customIconsInactiveFontFamily / customIconsActiveFontFamily / customIconsInactiveLineHeight / customIconsActiveLineHeight / customIconsInactiveFontWeight / customIconsActiveFontWeight / customIconsInactiveFontStyle / customIconsActiveFontStyle (仅适用于自定义图标) Custom icons for the tab bar, can be set individually for each tab. These properties are only valid when using the custom type of tab. For more information, please refer to the official documentation.
| zIndex Number The zindex of the tab bar, default is auto. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaInsetBottom Number The bottom inset of the safe area, default is auto. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaInsetTop Number The top inset of the safe area, default is auto. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaInsetLeft Number The left inset of the safe area, default is auto. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaInsetRight Number The right inset of the safe area, default is auto. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaBackgroundColor Color The background color of the safe area, default is transparent. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaBackgroundImage Image The background image of the safe area, default is none. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaCustomBackgroundColor Color The background color of the safe area when it overlaps with the content, default is transparent. This property is only valid when using the custom type of tab. For more information, please refer to the official documentation.
| safeAreaCustomBackgroundImage Image The background image of the safe area when it overlaps with the content, default is none. This property是纵向选项卡组件的使用方法,在小程序的app.json文件中,添加"usingComponents"字段,声明要使用的纵向选项卡组件:<
“`json
{
"usingComponents": {
"vantabs": "path/to/vantweapp/dist/tabs/index"
}
}
“`
在需要使用纵向选项卡组件的页面的json文件中,引入组件:
“`json
{
"usingComponents": {
"vantab": "path/to/vantweapp/dist/tabs/index"
}
}
“`
在页面的wxml文件中,添加纵向选项卡组件:
“`html
<vantabs>
<vantab title="标签1">内容1</vantab>
<vantab title="标签2">内容2</vantab>
<vantab title="标签3">内容3</vantab>
</vantabs>
“`
纵向选项卡组件的属性和方法
1、属性:
| 属性名 | 类型 | 默认值 | 说明 |
||||
| active | Number | 当前激活的标签索引,从0开始 | 当前激活的标签索引,从0开始 |
| animated | Boolean | true | true表示开启动画效果,false表示关闭动画效果 |
| duration | Number | 300 | animationDuration属性指定动画时长,单位为ms |
| color | String | #999999 | title文字颜色 |
| fontSize | Number | 14 | title文字大小