From e2a0738a8084f8e5b9a6383803edc46255eea229 Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Tue, 9 Apr 2019 09:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=20this.=5Fclass=20=3D=20'ActionTransf?= =?UTF-8?q?er'=20=E6=94=B9=E4=B8=BA=20this.=5Fclass=20=3D=20this.construct?= =?UTF-8?q?or.name=EF=BC=8C=E8=BF=99=E6=89=8D=E6=98=AF=E6=A0=87=E5=87=86?= =?UTF-8?q?=E5=86=99=E6=B3=95=EF=BC=8C=E4=B8=8D=E7=9F=A5=E9=81=93=E4=B8=BA?= =?UTF-8?q?=E4=BD=95ActionTranfer=E7=94=A8=E4=BA=86=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ActionTransfer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ActionTransfer.js b/ActionTransfer.js index 1be5793..3b570fb 100644 --- a/ActionTransfer.js +++ b/ActionTransfer.js @@ -1,9 +1,9 @@ const Action = require('./Action.js') const DAD = module.exports = function ActionTransfer (prop) { - this._class = 'ActionTransfer' + this._class = this.constructor.name this.setProp(prop) // 没有定义 ActionTransfer.prototype._model,因此继承了上级Action.prototype._model,因此通过this.setProp,继承了上级Action定义的实例自有数据。另一个方案是,调用 Action.call(this, prop) - this.type = 'ActionTransfer' + this.type = this.constructor.name } DAD.__proto__ = Action const MOM = DAD.prototype