From 7ba75cf15421df8c79ee0bbe68a76d9ac2e823f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E8=83=9C=E5=BC=BA?= Date: Thu, 15 Nov 2018 15:02:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A2=E5=BC=95=E5=88=97=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E5=9C=A8H5=E5=B9=B3=E5=8F=B0=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/template/index-list/index-list.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/hello-uniapp/pages/template/index-list/index-list.vue b/examples/hello-uniapp/pages/template/index-list/index-list.vue index 1777f8193..516c2b14c 100644 --- a/examples/hello-uniapp/pages/template/index-list/index-list.vue +++ b/examples/hello-uniapp/pages/template/index-list/index-list.vue @@ -38,19 +38,23 @@ touchmoveIndex: -1, itemHeight: 0, winHeight: 0, - scrollViewId: "A" + scrollViewId: "A", + titleHeight: 0 } }, onLoad() { let winHeight = uni.getSystemInfoSync().windowHeight; this.itemHeight = winHeight / 26; this.winHeight = winHeight; + //#ifdef H5 + this.titleHeight = 44 + //#endif }, methods: { touchStart(e) { this.touchmove = true; let pageY = e.touches[0].pageY; - let index = Math.floor(pageY / this.itemHeight); + let index = Math.floor((pageY - this.titleHeight) / this.itemHeight); let item = this.lists[index]; if (item) { this.scrollViewId = item.letter; @@ -59,7 +63,7 @@ }, touchMove(e) { let pageY = e.touches[0].pageY; - let index = Math.floor(pageY / this.itemHeight); + let index = Math.floor((pageY - this.titleHeight) / this.itemHeight); let item = this.lists[index]; if (item) { this.scrollViewId = item.letter; -- GitLab