Blogger Information
Blog 67
fans 0
comment 2
visits 72033
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
微信小程序左右联动子组件里面获取不到高height
搁浅
Original
357 people have browsed it
  1. let list = this.data.list;
  2. let tabHeight = 0;
  3. if (this.data.load) {
  4. for (let i = 0; i < list.length; i++) {
  5. let view = wx.createSelectorQuery().select("#main-" + i);//正常写法
  6. //子组件写法 let view = wx.createSelectorQuery().in(this).select("#main-" + i);
  7. view.fields({
  8. size: true
  9. }, data => {
  10. list[i].top = tabHeight;
  11. tabHeight = tabHeight + data.height;//子组件不加in(this),wx.createSelectorQuery()获取不到height
  12. list[i].bottom = tabHeight;
  13. }).exec();
  14. }
  15. this.setData({
  16. load: false,
  17. list: list
  18. })
  19. }
  20. let scrollTop = e.detail.scrollTop + 20;
  21. for (let i = 0; i < list.length; i++) {
  22. if (scrollTop > list[i].top && scrollTop < list[i].bottom) {
  23. this.setData({
  24. VerticalNavTop: (i - 1) * 50,
  25. TabCur: i
  26. })
  27. return false
  28. }
  29. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post