我在$('form').on('submit', function(e) {
// other code to handle visibility
$('.step2')[0].scrollIntoView();
// step2 is the class name of the second div
// that is to be visible
}
文件中实现了一个基本的网络套接字:
server.js
然后在我的const app = express();
const api = require('./server/routes/api');
app.use('/api', api);
const server = http.createServer(app);
const io = require('socket.io')(server);
io.on('connection', (socket) => {
console.log('user connected');
});
文件中,我需要套接字来发送数据:
api.js
但我无法访问router.post('/gmap', async (req, res) => {
const result = await callMap(req.body.data);
io.emit('updateMap', { data: result });
res.send(result);
});
对象。是否可以这样做?