简体   繁体   中英

How to switch content in Next.js

So I have a main dashboard on my app, in which I have a sidebar navigation and content container. But since I`m new to next.js and unfamiliar with its routing system, I don't know how to implement content changing when a user uses sidebar navigation. Should I make a separate page for each navigation route?

Yes, for each route your have to create a file in pages directory.

  • for route / you create the file pages/index.js
  • for route my-page you create the file pages/my-page.js
  • for route path/my-page you create the folder pages/path and the file pages/folder/my-file.js

For more explanation you can read the documentation of Next.js on routing . And you can also follow the official tutorial to get basic knowledge of Next.js.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM