提交 7ba75cf1 编写于 作者: 郭胜强

索引列表示例在H5平台索引错误的问题

上级 f10aefa4
...@@ -38,19 +38,23 @@ ...@@ -38,19 +38,23 @@
touchmoveIndex: -1, touchmoveIndex: -1,
itemHeight: 0, itemHeight: 0,
winHeight: 0, winHeight: 0,
scrollViewId: "A" scrollViewId: "A",
titleHeight: 0
} }
}, },
onLoad() { onLoad() {
let winHeight = uni.getSystemInfoSync().windowHeight; let winHeight = uni.getSystemInfoSync().windowHeight;
this.itemHeight = winHeight / 26; this.itemHeight = winHeight / 26;
this.winHeight = winHeight; this.winHeight = winHeight;
//#ifdef H5
this.titleHeight = 44
//#endif
}, },
methods: { methods: {
touchStart(e) { touchStart(e) {
this.touchmove = true; this.touchmove = true;
let pageY = e.touches[0].pageY; 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]; let item = this.lists[index];
if (item) { if (item) {
this.scrollViewId = item.letter; this.scrollViewId = item.letter;
...@@ -59,7 +63,7 @@ ...@@ -59,7 +63,7 @@
}, },
touchMove(e) { touchMove(e) {
let pageY = e.touches[0].pageY; 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]; let item = this.lists[index];
if (item) { if (item) {
this.scrollViewId = item.letter; this.scrollViewId = item.letter;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册