我正在尝试学习如何在浏览器中加载简单的ES6模块。自从我读到我希望用SystemJS做的那些浏览器不支持ES6模块。示例如下文件:
export class AbstractLogger {
constructor(name) {
console.log("Hello from constructor");
}
setNextLogger() {
console.log("Hello from method");
}
}
AbstractLogger.INFO = 1;
AbstractLogger.DEBUG = 2;
AbstractLogger.ERROR = 3;
当我使用SystemJS时,我收到以下错误。
SystemJS.import(' AbstractLogger.js&#39);
Uncaught (in promise) Error: XHR error: loading file:///home/tito/Projects/test/AbstractLogger.js
Instantiating file:///home/tito/Projects/test/AbstractLogger.js
Loading AbstractLogger.js
at XMLHttpRequest.error (system.src.js:1491)
at system.src.js:1528
at new Promise (<anonymous>)
at xhrFetch (system.src.js:1480)
at fetchFetch (system.src.js:1448)
at system.src.js:3394
at <anonymous>
如果我理解正确,我无法直接在浏览器中加载ES6模块,因为这不受支持。即使我提供了类型=&#39;模块&#39;在脚本标记中,这不起作用。那我们怎么想加载呢?我