我正试图导出这个js文件。
const student =
{
studentID : 1,
}
export {student}这是我要导入的第二个文件。
import {student} from "./studentId";
console.log(student);它不是导入它,而是抛出这个错误。
Failed to load resource: the server responded with a status of 404 ()发布于 2021-05-03 09:04:28
请查看错误消息。您将得到一个404未找到的错误。
加载模块时,Node.js不需要文件扩展名。它可以访问文件系统,并可以查看目录中的所有文件。
Web浏览器没有任何方法来判断您指定的URL是否应该有.js、.jsx、.mjs或.tsx或任何添加到其中的扩展。
您需要指定要导入的实际URL。
import {student} from "./studentId.js";https://stackoverflow.com/questions/67366158
复制相似问题