我想在我的 Node js 聊天应用程序中加载本地 jquery 文件。我搜索了很多,但找不到合适的解决方案。
<!doctype html>
<html>
<head>
<title>Socketio</title>
</head>
<body>
<!--This wont work -->
<script src="/socket.io/jquery.min.js"></script>
<!--This will work -->
<script src="/socket.io/socket.io.js"></script>
</body>
</html>
我只是将 jquery.js 文件复制到 socket.io
文件夹。socket.io.js
文件正确加载但 jquery 文件没有。请帮助我
这是我的 index.js 文件
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
server.listen(3000, function(){
console.log('listening on *:3000');
});
最佳答案
最后我找到了答案。我只是通过这种方式从本地主机加载jquery文件http://localhost/assets/jquery.min.js
。
关于javascript - 在 Node js中加载本地jquery.js文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27639683/