mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
[Improvement] Tab: add change event (#1503)
This commit is contained in:
parent
9da3e0ce5a
commit
b7b2ad9ffc
@ -165,4 +165,5 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content
|
|||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
|-----------|-----------|-----------|
|
|-----------|-----------|-----------|
|
||||||
| click | Triggered when click tab | index:index of current tab,title: tab title |
|
| click | Triggered when click tab | index:index of current tab,title: tab title |
|
||||||
|
| change | Triggered when active tab changed | index:index of current tab,title: tab title |
|
||||||
| disabled | Triggered when click disabled tab | index:index of current tab, title: tab title |
|
| disabled | Triggered when click disabled tab | index:index of current tab, title: tab title |
|
||||||
|
@ -167,5 +167,5 @@ export default {
|
|||||||
| 事件名 | 说明 | 参数 |
|
| 事件名 | 说明 | 参数 |
|
||||||
|-----------|-----------|-----------|
|
|-----------|-----------|-----------|
|
||||||
| click | 点击标签时触发 | index:标签索引,title:标题 |
|
| click | 点击标签时触发 | index:标签索引,title:标题 |
|
||||||
|
| change | 当前激活的标签改变时触发 | index:标签索引,title:标题 |
|
||||||
| disabled | 点击被禁用的标签时触发 | index:标签索引,title:标题 |
|
| disabled | 点击被禁用的标签时触发 | index:标签索引,title:标题 |
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ export default create({
|
|||||||
return {
|
return {
|
||||||
tabs: [],
|
tabs: [],
|
||||||
position: 'content-top',
|
position: 'content-top',
|
||||||
curActive: 0,
|
curActive: null,
|
||||||
lineStyle: {},
|
lineStyle: {},
|
||||||
events: {
|
events: {
|
||||||
resize: false,
|
resize: false,
|
||||||
@ -236,8 +236,14 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setCurActive(active) {
|
setCurActive(active) {
|
||||||
this.curActive = active;
|
if (active !== this.curActive) {
|
||||||
this.$emit('input', active);
|
this.$emit('input', active);
|
||||||
|
|
||||||
|
if (this.curActive !== null) {
|
||||||
|
this.$emit('change', active, this.tabs[active].title);
|
||||||
|
}
|
||||||
|
this.curActive = active;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// emit event when clicked
|
// emit event when clicked
|
||||||
@ -246,8 +252,8 @@ export default create({
|
|||||||
if (disabled) {
|
if (disabled) {
|
||||||
this.$emit('disabled', index, title);
|
this.$emit('disabled', index, title);
|
||||||
} else {
|
} else {
|
||||||
this.$emit('click', index, title);
|
|
||||||
this.setCurActive(index);
|
this.setCurActive(index);
|
||||||
|
this.$emit('click', index, title);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user