简体   繁体   English

从pug模板启动nodejs函数

[英]Launch nodejs function from pug template

I have a nodeJS server using express that is serving pages generated from a .pug. 我有一个使用express的nodeJS服务器,它提供从.pug生成的页面。

I want to have a button on this .pug which launched a function on the nodeJS server. 我想在这个.pug上有一个按钮,它在nodeJS服务器上启动了一个函数。

How can I do this? 我怎样才能做到这一点?

I suppose you can use socket.io to listen for an event from the front end and respond from the backend. 我想你可以使用socket.io来监听来自前端的事件并从后端做出响应。 I think an easier solution would be to have the button request an express route which runs the function 我认为更简单的解决方案是让按钮请求运行该功能的快速路线

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM