Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

javascript - Map() a list of menu items in React JS

I am using InertiaJs in my application. Also i have a list of menu items on UI where i use React JS. I map() this list of items like :

items.map(i => {
  return <InertiaLink href={route(i.path, route().params)}>{i.name}</InertiaLink>
})

route().params return the params of the accessed route. The menu works, but appear an issue when from the last menu item i want to go to the 2-ond for example. In this way i can not go back and i stay on the actual menu item. The issue is that when i want to go back clicking to one of the item i all params from the last route which i access with route().params seems to want to be applied on the previous even i don't have these params on the previous route.
Ex: last route has next params:

Route::get('/cars/colors/{nr}/list/{listNr}/item/{id}',....

So the nr, listNr and id will want to be applied to the previous menu item that i want to click.
Is somebody faced with the same issue and knows how t solve?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...