Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

Access Route Parameter from Blazor Navmenu

I have a dropdown in the NavMenu, whose selected value is passed in as a route parameter to all the sub-pages. On navigating to a new page, the selected value in the dropdown gets wiped because the NavMenu gets reinitialized. Question is whether there's any way to get this value fed back "up" into the NavMenu on a page load, so that the selected value in the dropdown is preserved.

question from:https://stackoverflow.com/questions/65865265/access-route-parameter-from-blazor-navmenu

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

1 Answer

0 votes
by (71.8m points)

The simplest and easiest way to do that is to store the selected value in the local storage, and whenever the NavMenu component is re-rendered, to read the stored value from the local storage, and apply it back to the dropdown


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...