diff --git a/example/pages/tabbar/index.wxml b/example/pages/tabbar/index.wxml
index b4ffab1e..b7858a6a 100644
--- a/example/pages/tabbar/index.wxml
+++ b/example/pages/tabbar/index.wxml
@@ -1,5 +1,10 @@
-
+
标签
标签
标签
@@ -8,13 +13,41 @@
-
+
- 自定义
-
-
+
+
+ 自定义
标签
标签
+
+
+
+ 标签
+ 标签
+ 标签
+ 标签
+
+
diff --git a/packages/tabbar-item/index.ts b/packages/tabbar-item/index.ts
index 159f2258..aaebf2e3 100644
--- a/packages/tabbar-item/index.ts
+++ b/packages/tabbar-item/index.ts
@@ -25,9 +25,9 @@ VantComponent({
this.$emit('click');
},
- setActive(active) {
+ setActive({ active, color }) {
if (this.data.active !== active) {
- this.set({ active });
+ this.set({ active, color });
}
}
}
diff --git a/packages/tabbar-item/index.wxml b/packages/tabbar-item/index.wxml
index 6f7251f1..cae5dcda 100644
--- a/packages/tabbar-item/index.wxml
+++ b/packages/tabbar-item/index.wxml
@@ -1,5 +1,6 @@
diff --git a/packages/tabbar/README.md b/packages/tabbar/README.md
index eb0ea6ed..7110d018 100644
--- a/packages/tabbar/README.md
+++ b/packages/tabbar/README.md
@@ -13,7 +13,6 @@
#### 基础用法
-
```html
标签
@@ -35,7 +34,6 @@ Page({
});
```
-
#### 自定义图标
可以通过 slot 自定义图标,其中 icon slot 代表未选中状态下的图标,icon-active slot 代表选中状态下的图标
@@ -43,9 +41,17 @@ Page({
```html
- 自定义
-
-
+
+
+ 自定义
标签
标签
@@ -68,11 +74,39 @@ Page({
});
```
+#### 自定义颜色
+
+```html
+
+ 标签
+ 标签
+ 标签
+ 标签
+
+```
+
+```javascript
+Page({
+ data: {
+ active: 0
+ },
+ // event.detail 的值为当前选中项的索引
+ onChange(event) {
+ console.log(event.detail);
+ }
+});
+```
+
### Tabbar API
| 参数 | 说明 | 类型 | 默认值 |
|-----------|-----------|-----------|-------------|
| active | 当前选中标签的索引 | `Number` | - |
+| active-color | 选中标签的颜色 | `String` | `#1989fa` |
| fixed | 是否固定在底部 | `Boolean` | `true` |
| z-index | 元素 z-index | `Number` | `1` |
| safe-area-inset-bottom | 是否适配iPhoneX | `Boolean` | `true` |
diff --git a/packages/tabbar/index.ts b/packages/tabbar/index.ts
index 3d3d6fd8..433c0a39 100644
--- a/packages/tabbar/index.ts
+++ b/packages/tabbar/index.ts
@@ -23,6 +23,7 @@ VantComponent({
props: {
active: Number,
+ activeColor: String,
fixed: {
type: Boolean,
value: true
@@ -52,7 +53,10 @@ VantComponent({
methods: {
setActiveItem() {
this.data.items.forEach((item, index) => {
- item.setActive(index === this.data.currentActive);
+ item.setActive({
+ active: index === this.data.currentActive,
+ color: this.data.activeColor
+ });
});
},