嗨,我是后端编程的新手,我正在尝试将对象数组发送到客户端,然后客户端将对象添加到数组中。我正在将 node.js 与 express.js 和 ejs 视图引擎一起使用。
这是我的代码:https : //www.w3schools.com/code/tryit.asp?filename=FVAMRIPCZT8J
我要发送的数组是形状。
在 ejs 你可以这样做:把它放在你的 ejs 文件中
var shapes = <%=the-Array-Of-Shapes%>
从路线使用:
app.get('/your-route',(req,res)=>{
res.render('your-ejs-file',the-Array-Of-Shapes);//here you are passing the array and the renderer will do the job
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句