javascript - How to separate front and backend using node?
仅有的幸福
仅有的幸福 2017-05-16 13:33:37
0
5
578

I recently did a small exercise using express+ jade + mongodb. The jade template engine used needs to embed js logic code in the page code when rendering data. I personally don’t like this development model, so I would like to ask how to use node. Achieve complete separation of front and backend?

仅有的幸福
仅有的幸福

reply all(5)
给我你的怀抱

The front-end and back-end separation pages must also be embedded js 代码啊,前端要跑的逻辑肯定还是得跑,express + jade Server-side rendering has been achieved, the front-end content is generated through the data rendering template, and the front-end then runs the corresponding front-end logic. This is considered complete separation.

巴扎黑

Let node be only responsible for the backend, and jade can be thrown away.
The front-end uses native js to perform an ajax request to obtain data, and then performs corresponding logical processing

迷茫

Using express + mongodb, the URL can be mapped to the database
———— In other words, the URL is a pointer to the data.

Adding a layer of jade to the express + mongodb technology means that the data must flow through jade, be coupled with the template into an html data stream, and then be returned to the client through response

Separation of front-end and back-end means that the data taken out from the database is directly returned to response
or processed by the template engine and then returned.

(Experience: res.jsonres.render)


给我你的怀抱

You can refer to Taobao’s front-end and back-end separation practice

The details are subject to discussion, but the general pattern is clearly explained. As it says in it, it depends on how you want the "front-end and back-end separation" to be separated. And your understanding of the front-end.

PHPzhong

Replace the jade template with html and use ajax on the front end. It will be ok. . . (The front end is equivalent to static resources, nodejs can be regarded as a web server)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!