如何从 hbs 分配 index.js 文件中存在的路由?
How to assign a route present in index.js file from hbs?
我想将在 views 文件夹下定义为 myprofile.hbs 的注销菜单项引用到 index.js
中定义的路由 /logout
我尝试将路径粘贴到该文件的 href= 中。
//里面有views/myprofile.hbs
<li>
<a href="./index.js/logout">
<i class="glyphicon glyphicon-log-out" id="signout"></i>
Sign Out </a>
</li>
//里面有index.js
app.get("/logout",function(req,res){
req.session.destroy();
res.redirect("/");
});
假设上面的 app.get()
是您应用程序的根目录,那么 href
只需 /logout
.
<a href="/logout">
匹配您在 Express 中的路径:
app.get("/logout"), . . .
我想将在 views 文件夹下定义为 myprofile.hbs 的注销菜单项引用到 index.js
中定义的路由 /logout我尝试将路径粘贴到该文件的 href= 中。
//里面有views/myprofile.hbs
<li>
<a href="./index.js/logout">
<i class="glyphicon glyphicon-log-out" id="signout"></i>
Sign Out </a>
</li>
//里面有index.js
app.get("/logout",function(req,res){
req.session.destroy();
res.redirect("/");
});
假设上面的 app.get()
是您应用程序的根目录,那么 href
只需 /logout
.
<a href="/logout">
匹配您在 Express 中的路径:
app.get("/logout"), . . .