index.js 694 B

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