From 280080bac6265105d4a45136f3f79efaa4d6090a Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Wed, 11 Nov 2020 17:52:09 +0800 Subject: [PATCH] 设计 Pilot 基类 --- bases/Pilot.js | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/bases/Pilot.js b/bases/Pilot.js new file mode 100644 index 0000000..a8fc753 --- /dev/null +++ b/bases/Pilot.js @@ -0,0 +1,32 @@ +/** + * Pilot + * @author Tevin + */ + +export class Pilot { + + constructor() { + } + + $data() { + return {}; + } + + createOptions() { + const options = { + methods: {}, + }; + Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(name => { + if (name === 'constructor' || name === '$methods') { + return; + } + if (/^\$/.test(name)) { + options[name.replace('$', '')] = this[name]; + } else { + options.methods[name] = this[name]; + } + }); + return options; + } + +} \ No newline at end of file -- Gitblit v1.9.1