一般來說目前開發(fā)web項(xiàng)目。涉及到套頁面的時(shí)候。方式有兩種。要么用模板語法類似jade(node),(php)smarty模板,razor(C#)等等這些。通過模板語法把后臺(tái)變量直接綁定到前端html上。這是一種選擇,大多數(shù)情況下這都是由后端程序員來完成的。還有一種綁定方式就是前端的MVC js框架。有knockout,angular之類。這些呢框架可以把后臺(tái)和前端完全隔離開,只通過異步請(qǐng)求的方式來拿數(shù)據(jù)。實(shí)現(xiàn)了前后端分離。我在想到底現(xiàn)在是哪種模式會(huì)比較好。因?yàn)榫退闶怯胊ngular來綁定數(shù)據(jù)。這些綁定工作一般來說還是由后端程序員來做。那到底在哪種情況下用模板語法比較適合,什么時(shí)候用angular這種。還算說跟公司的前端能力有關(guān)。因?yàn)楝F(xiàn)在我所在的公司這些事都是我來干。
人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!
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.