项目目录
--my_app
----node_modules
------axios
----index.html
----main.js
index.html 代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="main.js" type="module"></script>
</head>
<body>
</body>
</html>
main.js 代码:
import axios from "axios";
axios.get('http://localhost:5173/')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
浏览器 console 报错:
TypeError: Failed to resolve module specifier "axios". Relative references must start with either "/", "./", or "../".
搞不懂...
