index.js 613 B

12345678910111213141516171819202122232425262728
  1. import { getRect } from '../common/utils';
  2. import { VantComponent } from '../common/component';
  3. VantComponent({
  4. relation: {
  5. name: 'index-bar',
  6. type: 'ancestor',
  7. current: 'index-anchor',
  8. },
  9. props: {
  10. useSlot: Boolean,
  11. index: null,
  12. },
  13. data: {
  14. active: false,
  15. wrapperStyle: '',
  16. anchorStyle: '',
  17. },
  18. methods: {
  19. scrollIntoView(scrollTop) {
  20. getRect(this, '.van-index-anchor-wrapper').then((rect) => {
  21. wx.pageScrollTo({
  22. duration: 0,
  23. scrollTop: scrollTop + rect.top - this.parent.data.stickyOffsetTop,
  24. });
  25. });
  26. },
  27. },
  28. });