| | |
| | | methods: {}, |
| | | }; |
| | | const names = []; |
| | | let parent = null; |
| | | // 实例本身的字段 |
| | | Object.getOwnPropertyNames(this).forEach(name => names.push(name)); |
| | | // 类的字段 |
| | | Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(name => names.push(name)); |
| | | // 基类的字段,直到Pilot为止(不含Pilot) |
| | | parent = Object.getPrototypeOf(this); |
| | | while (parent instanceof Pilot) { |
| | | Object.getOwnPropertyNames(parent).forEach(name => names.push(name)); |
| | | parent = Object.getPrototypeOf(parent); |
| | | } |
| | | // 传递 |
| | | names.forEach(name => { |
| | | // 构造器忽略,如果存在属性 $methods 也忽略 |