uView ui 1.X 版本,u-index-list offset-top无效
uView ui 1.X 版本,u-index-list offset-top无效.md
进入原文件修改 u-index-list.vue

修改 getActiveAnchorIndex 方法

修改 scrollToAnchor 方法

getActiveAnchorIndex() {
const {
children
} = this;
const {
sticky
} = this;
for (let i = this.children.length - 1; i >= 0; i--) {
const preAnchorHeight = i > 0 ? children[i - 1].height : 0;
const reachTop = sticky ? preAnchorHeight : 0;
if (reachTop >= children[i].top-this.stickyOffsetTop) {
return i;
}
}
return -1;
},
scrollToAnchor(index) {
if (this.scrollToAnchorIndex === index) {
return;
}
this.scrollToAnchorIndex = index;
const anchor = this.children.find((item) => item.index === this.indexList[index]);
if (anchor) {
this.$emit('select', anchor.index);
uni.pageScrollTo({
duration: 0,
scrollTop: anchor.top + this.scrollTop - this.stickyOffsetTop
});
}
}

浙公网安备 33010602011771号