什么是客户端路由,如何使用? [英] What is client-side routing and how is it used?

查看:203
本文介绍了什么是客户端路由,如何使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人可以回答以下问题,我会很高兴

I will be glad if someone could answer the following questions


  1. 它是如何工作的?

  2. 为什么有必要?

  3. 有什么改进?


推荐答案

客户端路由与服务器端路由相同,但是它是在浏览器中运行的。

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

在典型的Web应用程序中,您会映射多个页面

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.

客户端路由只需在浏览器中运行此过程,就可以使用JavaScript来实现。逻辑和一些基于JS的模板引擎或其他此类方法来呈现页面。

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.

通常用于单页应用程序中,其中服务器端代码主要用于提供客户端代码通过Ajax使用的RESTful API。

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.

这篇关于什么是客户端路由,如何使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆