mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
* [improvement] Tab:升级到自定义组件 * fix: 去除冗余example代码 * [refactor] 重构badge为自定义组件 (#160) * fix: 去除tab组件使用对象入参方式,修改example用例
59 lines
938 B
JavaScript
59 lines
938 B
JavaScript
Component({
|
|
externalClasses: 'class',
|
|
|
|
properties: {
|
|
scroll: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
fixed: {
|
|
type: Boolean,
|
|
value: false
|
|
},
|
|
height: {
|
|
type: Number,
|
|
value: 0
|
|
},
|
|
list: {
|
|
type: Array,
|
|
value: []
|
|
},
|
|
selectedId: {
|
|
type: [String, Number],
|
|
value: '',
|
|
observer(newVal) {
|
|
this.setData({
|
|
currentTab: newVal
|
|
});
|
|
}
|
|
},
|
|
componentId: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
|
|
data: {
|
|
currentTab: ''
|
|
},
|
|
|
|
attached() {
|
|
this.setData({
|
|
currentTab: this.data.selectedId
|
|
});
|
|
},
|
|
|
|
methods: {
|
|
_handleZanTabChange(e) {
|
|
const selectedId = e.currentTarget.dataset.itemId;
|
|
|
|
this.setData({
|
|
currentTab: selectedId
|
|
});
|
|
|
|
console.info('[zan:tab:change] selectedId:', selectedId);
|
|
this.triggerEvent('tabchange', selectedId);
|
|
}
|
|
}
|
|
})
|