一般来说目前开发web项目。涉及到套页面的时候。方式有两种。要么用模板语法类似jade(node),(php)smarty模板,razor(C#)等等这些。通过模板语法把后台变量直接绑定到前端html上。这是一种选择,大多数情况下这都是由后端程序员来完成的。还有一种绑定方式就是前端的MVC js框架。有knockout,angular之类。这些呢框架可以把后台和前端完全隔离开,只通过异步请求的方式来拿数据。实现了前后端分离。我在想到底现在是哪种模式会比较好。因为就算是用angular来绑定数据。这些绑定工作一般来说还是由后端程序员来做。那到底在哪种情况下用模板语法比较适合,什么时候用angular这种。还算说跟公司的前端能力有关。因为现在我所在的公司这些事都是我来干。
PHP中文网2017-04-17 11:59:40
1. If you use Angular
, there are generally two types of data interaction between the front and back ends, one is through RESTful
, and the other is through the back end, as you said, rendering the data to the front end template. Go in. But no matter which method is used, the front-end engineer is required to be relatively proficient in Angular
. In this way, once you pass the data to the front-end, he will be able to handle it with ease.
2. Generally speaking, if Angular
is used, the development of the front-end and back-end are generally separated and there is not much interaction with each other. The front-end can simulate data by itself. You only need to connect the interface and test after both the front-end and back-end are developed. Check whether the data provided by the data interface is complete. That's basically it.
3. Regarding knockout
, I have never used it and don’t know much about it.
4. For some template engines, there may be more places to render data than the backend, and it is not very good for testing.
5. In short, it needs to be analyzed based on the specific situation of your company, and many factors must be considered. One is the company's front-end capabilities, and the other is a matter of time. Anyway, the development model that suits your company is the best.