的官方文档有一个从客户端socket.io导入和使用的示例,如下所示:socket.io
索引.html
<body>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$(function () {
var socket = io();
// Some other code in here...
});
</script>
</body>
现在我试图将我的js代码放在一个文件中(在文件夹main.js旁边)。这就是我所做的,这给了我:index.htmlpublicUnexpected identifier
main.js
import io from "../socket.io/socket.io.js"
const socket = io()
// Some other code here...
socket.io在这种情况下,正确的导入形式是什么?