back-top.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6. };
  7. import { SuperComponent, wxComponent } from '../common/src/index';
  8. import config from '../common/config';
  9. import props from './props';
  10. const { prefix } = config;
  11. const name = `${prefix}-back-top`;
  12. let BackTop = class BackTop extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.externalClasses = ['t-class', 't-class-icon', 't-class-text'];
  16. this.properties = props;
  17. this.data = {
  18. prefix,
  19. classPrefix: name,
  20. };
  21. }
  22. toTop() {
  23. this.triggerEvent('to-top');
  24. wx.pageScrollTo({
  25. scrollTop: 0,
  26. duration: 300,
  27. });
  28. }
  29. };
  30. BackTop = __decorate([
  31. wxComponent()
  32. ], BackTop);
  33. export default BackTop;