导入模块时收到错误:
import LobbyQueue from "./LobbyQueue";
错误在“ LobbyQueue”处。
这是LobbyQueue.js:
class LobbyQueue {
constructor() {
this.players = [];
}
enqueue(element) {
this.players.push(element);
}
dequeue() {
if (this.isEmpty()) {
return "Wait List Empty";
}
return this.players.shift();
}
first() {
if (this.isEmpty()) {
return "Wait List empty";
}
return this.players[0];
}
isEmpty() {
return this.players.length == 0;
}
getAll() {
return this.players;
}
}
export default LobbyQueue;
在index.js中导入为:
import LobbyQueue from "./LobbyQueue";
index.js和LobbyQueue.js位于同一目录
由于某种原因而无法识别LobbyQueue