uView ui 1.X 版本,u-index-list offset-top无效

uView ui 1.X 版本,u-index-list offset-top无效.md

进入原文件修改 u-index-list.vue
img

修改 getActiveAnchorIndex 方法
img

修改 scrollToAnchor 方法
img

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
					});
				}
			}
posted @ 2022-11-17 17:46  YSeventeen  阅读(560)  评论(0编辑  收藏  举报