Inheritance of the es6 class, Class constructor xxx cannot be invoked without 'new'

there is a class A , SubA inherits A, but the console reports an error Class constructor xxx cannot be invoked without "new" how to solve it?

//A
class A{
  constructor() {}
};

export default A
//A
import A from "xxx"
class SubA extends A{
  constructor() {
    super();
  }
};

export default SubA 
//
import A from "xxx"
import SubA from "xxx"

let B = new A(); //
let B0 = new SubA(); //

this error is very strange, there is nothing wrong with another program to do so, this is the problem here. The path of the file is checked correctly, and there is no error in the variable name.


Yes from not form


found the problem: File path problem . The file where
class An is located is in a folder at the same level in the static folder , although the referenced path is correct, but. For some reason, it's just wrong.
change the file where class An is located to src folder , and just. It's normal.

latest solution: this error occurs because the file where class An is located is outside the src folder and is not packaged by webpack so that the syntax cannot be recognized. You can convert the file with babel.

Menu