嗨,我是后端编程的新手,我正在尝试向客户端发送一个对象数组,然后客户端将一个对象添加到该数组中。我正在使用带有express.js和ejs视图引擎的node.js。
下面是我的代码:https://www.w3schools.com/code/tryit.asp?filename=FVAMRIPCZT8J
我想要发送的数组是shapes。
发布于 2018-09-16 00:41:56
在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
})
https://stackoverflow.com/questions/52345978
复制相似问题