NODEJS:一次发送文件和数据 [英] NODEJS: Send a file and data at once
本文介绍了NODEJS:一次发送文件和数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是我得到的.效果很好,但我希望能够在客户端登录我的网站时将文件和数据(JSON)发送给客户端.有什么办法可以结合起来吗?
This is what I got. It works great but I'd like to be able to send a file and data (JSON), to the client when he logs in my website. Is there any way to combine that?
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
推荐答案
您不能一次发送2个文件.但是您可以使用带有ejs
的模板库将JSON嵌入html中.
You can't send 2 files at once. But you can embed the JSON inside the html by using a template library with ejs
.
这篇关于NODEJS:一次发送文件和数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文