Browse Source

修复mitt无法继承问题

bill 2 years ago
parent
commit
ae48988ed8
1 changed files with 7 additions and 3 deletions
  1. 7 3
      src/graphic/Layer.js

+ 7 - 3
src/graphic/Layer.js

@@ -24,9 +24,8 @@ import History from "./History/History";
 import { keyService } from "./Service/KeyService";
 import mitt from "mitt";
 
-export default class Layer extends mitt {
+export default class Layer {
   constructor(canvas) {
-    super();
     this.canvas = canvas;
     this.load = new Load(this);
 
@@ -37,7 +36,12 @@ export default class Layer extends mitt {
     this.display = false;
     this.mousePosition = null;
 
-    this.start();
+    setTimeout(() => {
+      console.log(this);
+      this.start();
+    });
+
+    Object.setPrototypeOf(Object.getPrototypeOf(this), mitt());
   }
 
   start() {