index.js 649 B

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