- SPA搜到是
水疗emmmm…而此处浅谈单页Web应用(single page web application,SPA) - 首先一个网站一个页面????表示很疑惑
单页面应用,就是把整个项目的所有页面的所有内容分成了很多的小块(就是组件),可以重复利用的,可以任意调整的组件,每个组件就是一个独立的部分(包括html,css和javascript代码)。再做一个html(基本上啥也没有),这个html就是一个页面容器,需要放那个组件时,直接引入就行。跳转时,直接跳转组件就行。当需要加载某个组件时,js会动态创建这些组件里的HTML,CSS。增加了同一网站中各网页相同组件的复用,减少了网络请求时间。用户体验更好。
转载:https://blog.csdn.net/jiang7701037/article/details/93243545(本文还介绍了传统多页面网站和单页面的对比)
- 单页面的应用优点:
1.分离前后端关注点,前端负责界面显示,后端负责数据存储和计算。不会把前后端的逻辑
混杂在一起;
2.减轻服务器压力,服务器只用出数据就可以;
3.同一套后端程序代码,不用修改就可以用于Web界面、手机、平板等多种客户端;
4.用户体验好、快,内容改变不需要重新加载整个页面,web应用更具响应性和更令人着迷;
5.SPA和RESTful架构一起使用,后端不再负责模板渲染、输出页面工作,web前端和各种
移动终端地位对等,后端API通用化;
- 单页面的应用缺点:
1.初次加载耗时相对增多;
2.导航不可用,如果一定要导航需要自行实现前进、后退,需要程序来实现管理;
3.使用脚本修改页面,这个脚本我们都知道,他的兼容性是个大问题;
4.不利于SEO(搜索引擎优化)问题,现在可以通过Prerender等技术解决一部分;
转载:https://blog.csdn.net/weixin_41646716/article/details/80073995