javascript - 单页与后端模版渲染方式的取舍?
现在流行2种开发方式:
1,单页
前端通过AngularJs、EmberJs或者ReactJs等写单页应用,后端只提供数据接口,在后端看来前端页面和手机App没有区别,前后端完全分离。例子:印象笔记
2,后端模版渲染
前端给后端提供写好的页面,让后端写模版引擎渲染页面,这是比较传统的方法,除了写模版引擎渲染页面工作,后端还要单独给手机App提供接口,前端一般比较轻松,写静态页面就可以了,例子:大部分网站,比如segmentfault
问题来了,如果网站之前是传统的后端模版渲染方式,后来上了手机端,后端也给手机提供了接口,那么为了一致性、后端维护成本考虑,我有必要把网站也改为单页应用的方式吗?
回复内容:
现在流行2种开发方式:
1,单页
前端通过AngularJs、EmberJs或者ReactJs等写单页应用,后端只提供数据接口,在后端看来前端页面和手机App没有区别,前后端完全分离。例子:印象笔记
2,后端模版渲染
前端给后端提供写好的页面,让后端写模版引擎渲染页面,这是比较传统的方法,除了写模版引擎渲染页面工作,后端还要单独给手机App提供接口,前端一般比较轻松,写静态页面就可以了,例子:大部分网站,比如segmentfault
问题来了,如果网站之前是传统的后端模版渲染方式,后来上了手机端,后端也给手机提供了接口,那么为了一致性、后端维护成本考虑,我有必要把网站也改为单页应用的方式吗?
给你做个对比表:
招个全栈开发,首屏服务器端渲染好,后面交互,前端js继续写。我们基于react前后端统一。 后端分了两层 最外一层也是前端负责 node写 另一个端 是python写的 那人兼职DBA 就酱紫。
之前尝试过用node来渲染view,现在在用angular渲染view,总结下来,感觉后者更通用一点,因为只要把接口明确了,后端换啥都能接,而后端也一样,只要定好api,前端换啥都能接。
低耦合,方便二次开发。
现在一种趋势了。很多东西都是移动端,WEB,WAP。我们是不是应该写一套接口,可以让三个端来调用。现在也流行了这样的趋势。前端走MVC,服务端把view层砍掉,走restful风格,专注于数据的业务逻辑和处理。
如果都是restful api的话,没什么关系呀。你也可以用node.js来做后端渲染,工作量就在你这边了。
单页前端渲染 seo不好做

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
