我如何在 Go 中使用 React Router?例如,我在 Go 中有這個(gè):Echo.Get("/*", *handler which return page with ReactRouter*)這在 React Router 中:React.render((<Router history={History.createHistory()}> <Route name="index" path="/" component={Main}> <Route name="users" path="/users" component={Users}> <Route name="user" path="/user/:userId" component={User} /> </Route> <Route path="*" component={NotFound} /> </Route></Router>), document.body)但是我一直在獲取索引 (/) 頁面。所有路由的行為都相同('/'、'/users'、'/user/qwe' 等)
1 回答

Helenr
TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超4個(gè)贊
您必須使用新綁定呈現(xiàn)不同的路由,或者在處理程序函數(shù)中專門處理該綁定并讀出請求對象的信息。
Echo.Get("/user/:id", getUser)
Echo.Get("/users", listUsers)
Echo.Get("/*", catchAllRemainingCalls)
希望這可以幫助。祝你好運(yùn)!
- 1 回答
- 0 關(guān)注
- 202 瀏覽
添加回答
舉報(bào)
0/150
提交
取消