修复选中bug
This commit is contained in:
parent
bc819831f0
commit
26e596dd21
|
@ -62,8 +62,10 @@ export default {
|
|||
itemId: "", // 栏目右边scroll-view用于滚动的id
|
||||
arr: [], // 储存距离顶部高度的数组
|
||||
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
|
||||
timer: null, // 定时器
|
||||
wrapHeight: 0,
|
||||
// 按ID选择
|
||||
timer: null,
|
||||
activeIndex: 0,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
|
@ -237,14 +239,19 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
switchCate(id) {
|
||||
let idx = 0;
|
||||
/**
|
||||
* 按ID选中
|
||||
*/
|
||||
async switchCate(id) {
|
||||
if (this.arr.length == 0) {
|
||||
await this.getMenuItemTop();
|
||||
}
|
||||
this.data.forEach((item, index) => {
|
||||
if (item.id == id) {
|
||||
idx = index;
|
||||
this.activeIndex = index;
|
||||
}
|
||||
});
|
||||
this.swichMenu(idx);
|
||||
this.swichMenu(this.activeIndex);
|
||||
},
|
||||
clickItem(id) {
|
||||
this.$emit("clickItem", id);
|
||||
|
@ -254,6 +261,15 @@ export default {
|
|||
activeId(activeId) {
|
||||
this.switchCate(activeId);
|
||||
},
|
||||
arr(arr) {
|
||||
clearTimeout(this.timer);
|
||||
if (this.activeIndex > 0) {
|
||||
const that = this;
|
||||
this.timer = setTimeout(() => {
|
||||
that.scrollRightTop = arr[that.activeIndex];
|
||||
}, 200);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue