Answer the question
In order to leave comments, you need to log in
How to implement pages in SPA?
The question is probably some kind of strange, because there should be one page in SPA)
The bottom line is that often when implementing single-page applications, there is a need to implement "pages" (screens, activities). I made an application on the backbone and reinvented the wheel with $.get() and templates in different files, I had to monitor DOM events and load css in semi-automatic mode (((.
The essence of the question is, are there any ready-made solutions or practices, for some reason it seems that I saw something similar in React.
I hope I explained the problem clearly enough. How to implement different screens in a single-line application? Tell me where to dig.
UPD. Yes, I used a router, but roughly speaking, it just reports that the url has changed. I wanted to ask about the very implementation of loading another screen.
UPD2. For example, there are two pages: Profile and dialogs, with completely different markup. There are header and footer, which are the same on all pages. How to implement a markup change in spa when switching to a profile or dialogs.
Answer the question
In order to leave comments, you need to log in
So the router! Use different urls to connect the required component. routes can be grouped for pages of the same type.
https://github.com/xmoonlight/includeHTML
A modern JavaScript router in 100 lines
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question