What is client-side routing and how is it used?

前端 未结 2 1046
清酒与你
清酒与你 2020-12-13 11:14

I will be glad if someone could answer the following questions

  1. How does it work?
  2. Why is it necessary?
  3. What does it improve?
2条回答
  •  旧巷少年郎
    2020-12-13 11:52

    Client side routing is the same as server side routing, but it's ran in the browser.

    In a typical web application you have several pages which map into different URLs, and each of the pages has some logic and a template which is then rendered.

    Client-side routing simply runs this process in the browser, using JavaScript for the logic and some JS based template engine or other such approaches to render the pages.

    Typically it's used in single page applications, where the server-side code is primarily used to provide a RESTful API the client-side code uses via Ajax.

提交回复
热议问题