为什么我的默认值 class 不能在 ES6 中导入?
Why won't my default class import in ES6?
我是第一次在 webpack 中使用 babel-loader,我也是 ES6 的新手。我正在尝试从一个文件导出基础 class 并将其导入另一个文件。到目前为止,导出和导入在我的整个文件中都运行良好,现在我在尝试创建 classes.
时第一次遇到问题
我的代码如下所示:
BaseClient.js
export default class BaseClient {
// snip...
};
SessionClient.js
import BaseClient from './BaseClient';
// outputs "undefined":
console.log(BaseClient);
// throws "Uncaught TypeError: Super expression must either be null or a function, not undefined":
export default class SessionClient extends BaseClient {
// snip...
};
我是不是做错了什么?在诊断之前,我的问题中是否缺少任何相关信息?谢谢!
是的,我也遇到了这个问题。这是由于在很长的引用链中不同文件之间的循环引用造成的。
喜欢以下内容:
我是第一次在 webpack 中使用 babel-loader,我也是 ES6 的新手。我正在尝试从一个文件导出基础 class 并将其导入另一个文件。到目前为止,导出和导入在我的整个文件中都运行良好,现在我在尝试创建 classes.
时第一次遇到问题我的代码如下所示:
BaseClient.js
export default class BaseClient {
// snip...
};
SessionClient.js
import BaseClient from './BaseClient';
// outputs "undefined":
console.log(BaseClient);
// throws "Uncaught TypeError: Super expression must either be null or a function, not undefined":
export default class SessionClient extends BaseClient {
// snip...
};
我是不是做错了什么?在诊断之前,我的问题中是否缺少任何相关信息?谢谢!
是的,我也遇到了这个问题。这是由于在很长的引用链中不同文件之间的循环引用造成的。
喜欢以下内容: