瀏覽代碼

移动端 事件/Scope

luoyifan 3 年之前
父節點
當前提交
ce275c7309
共有 1 個文件被更改,包括 28 次插入39 次删除
  1. 28 39
      src/Scope.ts

+ 28 - 39
src/Scope.ts

@@ -121,37 +121,6 @@ export class Scope {
                 viewModel: vmodel,
                 yvanScope: this,
                 referenceHolder: true,
-
-                listeners: {
-                    renderedchange(sender, item, rendered, opts) {
-                        // 记录句柄
-                        if (rendered) {
-                            that._handle = this
-                            window['cp'] = that
-
-                            // 调用onLoad回调
-                            try {
-                                that._onLoad(sender)
-                            } catch (e) {
-                                console.error('errorAt onLoad', e)
-                            }
-
-                            const $back = $(sender.el.dom)
-                                .find('.navbar>.x-panelheader')
-                                .find('.x-body-el>.fa-angle-left')
-                            $back.on('click', () => {
-                                that._handle.close()
-                            })
-                        }
-
-                        // 如果vjson中配置了 afterrender ,需要恢复状态
-                        if (typeof that.vjson.listeners?.renderedchange === 'function') {
-                            that.vjson.listeners.renderedchange.apply(this, arguments)
-                        }
-
-                        this.fireEvent('afterrender', sender)
-                    },
-                },
             },
             vjsonOption,
             that.vjson,
@@ -176,15 +145,28 @@ export class Scope {
 
         this.viewModel = that._handle.getViewModel()
         this.viewModel.yvanScope = this
-
-        Ext.Viewport.add(that._handle)
-
-        // that._handle = Ext.Viewport.add(config)
-        if (allowBack) {
-            that._handle.show();
-        }
-
         that._handle.on({
+            renderedchange(sender, item, rendered, opts) {
+                // 记录句柄
+                if (rendered) {
+                    that._handle = this
+                    window['cp'] = that
+
+                    // 调用onLoad回调
+                    try {
+                        that._onLoad()
+                    } catch (e) {
+                        console.error('errorAt onLoad', e)
+                    }
+
+                    const $back = $(sender.el.dom)
+                        .find('.navbar>.x-panelheader')
+                        .find('.x-body-el>.fa-angle-left')
+                    $back.on('click', () => {
+                        that._handle.close()
+                    })
+                }
+            },
             destroy() {
                 // 卸载
                 window['cp'] = Ext.Viewport.items.getAt(Ext.Viewport.items.items.length - 2).getViewModel().yvanScope
@@ -192,6 +174,13 @@ export class Scope {
             }
         })
 
+        Ext.Viewport.add(that._handle)
+
+        // that._handle = Ext.Viewport.add(config)
+        if (allowBack) {
+            that._handle.show();
+        }
+
         return that._handle
     }