lifecycle.js 633 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. let logs = [];
  2. export default {
  3. onLoad() {
  4. this.data = this.data || {};
  5. this.data.debug = !!0;
  6. this.log(`${this.data.pageName} onLoad`);
  7. },
  8. onUnload() {
  9. this.log(`${this.data.pageName} onUnload`);
  10. },
  11. onShow() {
  12. this.log(`${this.data.pageName} onShow`);
  13. },
  14. onHide() {
  15. this.log(`${this.data.pageName} onHide`);
  16. },
  17. onReady() {
  18. this.log(`${this.data.pageName} onReady`);
  19. },
  20. showLogs() {
  21. console.log(logs.join('\n'));
  22. my.alert({
  23. title: 'logs',
  24. content: logs.join('\n'),
  25. });
  26. },
  27. clearLogs() {
  28. logs = [];
  29. },
  30. log(str) {
  31. logs.push(str);
  32. },
  33. };