目前在我的Node应用程序中有以下url结构:
http://localhost:3000/#record_2
点击像上面这样的链接,将网页滚动到id为record_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('/')
})
我不需要#record_?要在服务器上处理的段。我怎样才能得到测试部分返回到我的服务器代码进行处理?
路径段和查询选项必须在散列符号http://localhost:3000/?test=2#record_2
或http://localhost:3000/test/2/#record_2
之前变为