2. The front-end routing of personal understanding

Foreword

  Appears on the front end of the route, I always had a question. The front end of the route in the end why exist only to realize SPA it? With questions, I check a lot of books and data network, in which data are when it comes to the point, that is the back-end development process, achieve back-end routing code Kang Shen. Greatly increased the pressure on the server. The front-end routing and thus also born. Will be achieved by the rear into the front end of the route, to reduce the pressure on the server. In fact, not the case. Next, I would record myself to an understanding of front-end routing it

 

1. The birth of the front end of the route

  The presence of front-end route to the user without refreshing the underlying page on the realization of refreshing data. That is, enhance the user's interactive experience. Now, when it comes to the underlying page does not refresh to refresh the data is achieved, it would say to the AJAX technology.

  AJAX technology, the full name of Asynchronous JavaScript And XML. Browser is a technical solution to the asynchronous load data. If there is no ajax technology, when the user submits the data is bound to refresh the page to load, it will affect other data. Reset phenomenon. To solve this problem, therefore, AJAX technology emerged. Since AJAX implementation of asynchronous data loading, enhancing the user's interactive experience, what more advanced version of the interactive user experience is? At present, there is no doubt that SPA, that is, single-page application. The concept of single-page application is accompanied by the emergence of MVVM. Users can achieve a variety of interactive features through a single-page page application, without the need to refresh the page. Of course, not just a single page application listed in the interactive page without refreshing, even the page jump it is not flushed. In order to achieve this more advanced version of AJAX technology. So front-end routing born.

 

2. The principle of front-end route

  Intrinsically the URL to the front end of the route is a function of one of the mapping mode, it can be said change detection URL, the URL is intercepted by the address, then parse the routing rule to match (or by a change in the intercepted URL address, to resolve the match corresponding to the function, and then execute the corresponding function), more popular to say that the "front-end routing" word too bluffing, that is to trigger a click onclick event, and then modify the DOM node through this event, let it show or hide. Just click on the front end of the route is "<a>" link, href value "<a>" added a link in the "#" symbol, the browser will not see this symbol is resolved, it will not jump turn the page. At the same time triggering a window.hashchange event is triggered each time point # of <a> have time, then you can write a function to manipulate the dom (change display).

 

Put a guess:

  Since the SPA is an advanced version of single-page AJAX application, that would mean that more advanced version is "offline"? , How is the feeling APP

Guess you like

Origin www.cnblogs.com/qfshini/p/12118946.html