【类 型】:fix
【主 题】:导航栏bug 【描 述】: [原因]:每次点击导航栏 右侧内容栏滚动 反向导致 导航栏乱跳bug [过程]:点击时加个标记 定时删除标记 [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
d2c0364cbf
commit
dd243e84da
@ -116,6 +116,7 @@
|
||||
timer: null, // 定时器
|
||||
|
||||
isScrollingByClick: false, // 添加这个标志 解决点击左侧导航栏点击 右侧内容滚动之后 反过来影响左侧导致跳变
|
||||
scrollingTiemout: null, //timeout对象
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
@ -168,16 +169,21 @@
|
||||
totalPrice,
|
||||
// 点击左边的栏目切换
|
||||
async swichMenu(index) {
|
||||
clearTimeout(this.scrollingTiemout) //每次点击导航栏重置timeout延时
|
||||
this.isScrollingByClick = true
|
||||
if (this.arr.length == 0) {
|
||||
await this.getMenuItemTop()
|
||||
}
|
||||
if (index == this.current) return
|
||||
this.scrollRightTop = this.oldScrollTop
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(function() {
|
||||
this.scrollRightTop = this.arr[index]
|
||||
this.current = index
|
||||
this.leftMenuStatus(index)
|
||||
})
|
||||
this.scrollingTiemout = setTimeout(() => {
|
||||
this.isScrollingByClick = false
|
||||
}, 800)
|
||||
},
|
||||
// 获取一个目标元素的高度
|
||||
getElRect(elClass, dataVal) {
|
||||
@ -264,8 +270,10 @@
|
||||
let height2 = this.arr[i + 1]
|
||||
// 如果不存在height2,意味着数据循环已经到了最后一个,设置左边菜单为最后一项即可
|
||||
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
|
||||
this.leftMenuStatus(i)
|
||||
console.log('hi')
|
||||
if (!this.isScrollingByClick) {
|
||||
this.leftMenuStatus(i)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}, 10)
|
||||
|
Loading…
Reference in New Issue
Block a user