【发布时间】:2022-08-24 05:23:43
【问题描述】:
我目前在我的 Node 应用程序中有以下 url 结构:
http://localhost:3000/#record_2
单击类似上面的链接会将网页滚动到具有匹配 id 的元素记录_2.
但是我需要可以在我的 Express 路径中检测和使用的额外信息。我尝试了以下方法:
http://localhost:3000/#record_2?test=2
http://localhost:3000/#record_2/test/2
但是,使用以下代码无法识别我的路径:
app.get(\'/#:record/test/:id\', async (request, response) => {
console.log(\'Request: \', request.params)
response.redirect(\'/\')
})
app.get(\'/#:record?test=:id\', async (request, response) => {
console.log(\'Request: \', request.params)
response.redirect(\'/\')
})
我不需要#记录_???要在服务器上处理的段。我怎样才能得到测试部分返回我的服务器代码进行处理?
标签: node.js express path anchor