简体   繁体   English

使用 EJS 进行服务器端渲染

[英]Server side rendering with EJS

I think I have a misunderstanding of server side rendering with ejs.我想我对 ejs 的服务器端渲染有误解。

Per my understanding, when we create an ejs template and do根据我的理解,当我们创建一个 ejs 模板并做

res.render('home.ejs')

The entire page is created in the server side.整个页面都是在服务器端创建的。 The page will contain all of the images and libraries pre loaded.该页面将包含所有预加载的图像和库。 This is then sent to the browser where the DOM event handler javascript code is run然后将其发送到运行 DOM 事件处理程序 javascript 代码的浏览器

Is this understanding correct?这种理解是否正确?

What is ejs: Point we should focus to understand ejs: EJS makes easy to write HTML and just that, nothing more, nothing less.什么是 ejs:我们应该重点理解 ejs:EJS 使编写 HTML 变得容易,仅此而已,仅此而已。

How it works:In general we can not write plain javascript inside html but through ejs we can do that.工作原理:通常我们不能在 html 中编写普通的 javascript,但通过 ejs 我们可以做到。 Previously we have to organize javascript code but now we don't need to be panic about it.以前我们必须组织 javascript 代码,但现在我们不必为此感到恐慌。 Just write plain javascript inside html.只需在 html 中编写普通的 javascript。

Hence you said 'The entire page is created in the server side' is actually a wrong statement.因此,您说“整个页面是在服务器端创建的”实际上是错误的陈述。 Thank you so much.非常感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM