【发布时间】:2019-04-20 19:53:49
【问题描述】:
我正在用 Node JS 编写代码,它使用 mustache 模板化 html 和 REST API 作为后端。
这是我的代码不起作用。
function setupRoutes(app) {
const base = app.locals.base;
app.get(`${base}/search.html`,doSearchContent(app));
app.get(`${base}/:name`,doGetContent(app));
}
function doSearchContent(app) {
return async function(req, res) {
console.log("here");
}; };
当我运行我的程序并转到 base/search.html 时。它从不调用 doSearchContent 方法。
知道为什么以及如何解决这个问题吗?
编辑:doGetContent 按预期工作。当我运行 search.html 时它没有
【问题讨论】:
-
您能分享一下您使用的框架吗?您正在使用某种路由器。