我目前在我的 Node 應用程式中有以下 url 結構:
http://localhost:3000/#record_2
單擊類似上面的鏈接會將網頁滾動到匹配 id 為record_2的元素。
但我需要可以在我的快速路徑中檢測和使用的額外資訊。我嘗試了以下方法:
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_??? 要在服務器上處理的段,但我需要幫助將測驗部分回傳到我的服務器代碼進行處理。
我會很感激一些幫助。
uj5u.com熱心網友回復:
路徑段和查詢選項必須位于井號之前:http://localhost:3000/?test=2#record_2
或http://localhost:3000/test/2/#record_2
。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/489768.html