From 5c951eee9ef2b2d57bc6f08b10d21347d01ec538 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Wed, 16 Dec 2020 19:23:47 +0800
Subject: [PATCH] 优化 Pilot 基类

---
 bases/Pilot.js |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/bases/Pilot.js b/bases/Pilot.js
index bc09f48..c92522b 100644
--- a/bases/Pilot.js
+++ b/bases/Pilot.js
@@ -16,7 +16,14 @@
         const options = {
             methods: {},
         };
-        Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(name => {
+        const names = [];
+        // 实例本身的字段
+        Object.getOwnPropertyNames(this).forEach(name => names.push(name));
+        // 类的字段
+        Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(name => names.push(name));
+        // 传递
+        names.forEach(name => {
+            // 构造器忽略,如果存在属性 $methods 也忽略
             if (name === 'constructor' || name === '$methods') {
                 return;
             }

--
Gitblit v1.9.1