更新服务器端渲染客户端 [英] Updating server-side rendering client-side

查看:69
本文介绍了更新服务器端渲染客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器端模板引擎Jade,用于渲染布局.当客户第一次收到版式时,版式的内容中只会出现一些可能需要更新的较小更改,而不是版式本身.

I have a server-side templating engine, Jade, which I use to render a layout. When the client receives the layout for the first time, there will only be small subsequent changes in the contents of the layout that may need updating, not the layout itself.

有没有一种方法可以通过仅更改需要更新的内容并同时使用Jade的功能来渲染"客户端.

Is there a way to "rerender" client-side by only changing what needs to be updating, and at the same time using the power of Jade.

推荐答案

您可以通过 socket.io 完成操作目前正在node.js中开发该程序以实现该功能并具有可运行的原型- https://github.com/parj/tableUpdates/tree/tableUpdate

You can do it via socket.io, I am currently developing the program in node.js to do it and have a working prototype - https://github.com/parj/tableUpdates/tree/tableUpdate

该视图使用玉渲染到服务器端.需要更改的组件,我从服务器端发送一个json,在客户端解析它,然后仅使用JavaScript更新所需的组件.

The view is rendered server side using jade. The components that need changing, I send a json from the server side, parse it on the client side and only update the required component using JavaScript.

在server.js中,您可以看到我放在一起然后发出的可变货币的json.在客户端上,它是在public/javascript/buildtable.js

In server.js, you can see the json in variable currencies I put together and then emit. On the client it is received and handled in public/javascript/buildtable.js

我已经上传了最新的代码-server.js每秒运行一次randomChanges()并将随机JSON数据发送到客户端.客户端在收到重建表之后.希望这就是您想要的.

I have uploaded the latest code - server.js runs randomChanges() every second and sends random JSON data to the clients. The clients upon receiving rebuild a table. Hope this is what you are looking for.

这篇关于更新服务器端渲染客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆