custom-loading.js 539 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Component({
  3. props: {
  4. hidden: true,
  5. duration: 1500,
  6. textContent: '',
  7. onLoadChange: function onLoadChange() {}
  8. },
  9. methods: {
  10. watchHidden: function watchHidden() {
  11. var num = Number(this.props.duration);
  12. if (!this.props.hidden) {
  13. var that = this;
  14. setTimeout(function () {
  15. var e = {
  16. type: 'change'
  17. };
  18. that.props.onLoadChange(e);
  19. }, num);
  20. }
  21. }
  22. },
  23. didUpdate: function didUpdate() {
  24. this.watchHidden();
  25. }
  26. });