Comments (1)
这是老ER的问题。新ER里其实也有相应的机制,只不过不在ER这个repo下了。
首先,这基于一种假设:我们认为页面不一定是需要全部变化的。比如我们进入一个列表页面,然后点击了第二页,这时列表的表头可以不用变化,只局部刷新表格的内容区域。要实现这样的场景,我们需要知道什么东西是可变化的。通常情况下,有两种做法:
- 自动法:当render时,抽析出模板中变量的部分。这种做法用起来比较方便,但实际上比较麻烦。首先变化的一定是页面中的DOM,但你render的时候面对的是字符串,你需要按相应的规则parse出变化的部分(对应的是什么变量,属于DOM中的什么部分,text还是attr等),才能方便的构建映射。后续更新时,对于复杂的数据结构,你可能需要做diff,这个开销是很大的。
- 手动法:手工标识哪些东西是可变的。这个听起来不太现实,使用太麻烦了。但老ER正是这么做的,不是全手工,但是基于了一些规则。
老ER的做法是:
- 视图渲染的步骤,在框架层面做了一层抽象,分成render和repaint。当页面首次进入时,进入render过程;当二次进入(hash的path部分不变,参数变化时),进入repaint过程。这个抽象便于在视图渲染中实现局部刷新。但是ER并没规定一定要做这事。
- 视图render的步骤是:通过模板引擎填充HTML -> 渲染UI组件(初始化组件 -> 在当前环境下保存组件的引用 -> 为组件填充数据 -> 调用组件的render方法)
- 在上面的步骤中,视图能够知道当前有哪些组件,每个组件使用哪些数据了。这时候后面的局部刷新就好做了。在视图repaint中,我们只对组件进行刷新,步骤如下:遍历所有组件 -> 填充数据 -> 调用组件的render方法。
从上面的几点可以看出来:
- 局部刷新是由UI组件完成的(一个Table组件,第二次render的时候,只刷数据区域还是刷新全部,这件事情交给Table组件来决定。一个Select,value变化时只刷新显示区域这种事情也是Select自己完成)
- 视图缓存也是UI组件完成的(数据不变的时候,视图是否重新刷新,这个逻辑也交给UI组件)
综上,对老ER和ESUI集成的默认方案来说,我们认为UI组件是数据显示与变化的载体
。对于你上面的case,建议使用Label组件来承载需要变化的红框文字内容。
from er.
Related Issues (20)
- 子Action中a标签外跳到一个er path的需求 HOT 7
- [template]etpl2/3从Model中取值问题 HOT 2
- deferred中加入一个方法控制串行请求合适么? HOT 9
- controller#forward,mix options给actionContext会出问题 HOT 2
- 两层以上的ChildAction里发生global redirect的时候会报错 HOT 6
- 页面切换次数多了的时候,会出现hash跳转了但是view没渲染的情况 HOT 24
- 开放路径访问权限方法 HOT 1
- enteractionfail事件增加参数
- ER 不在npmjs.org 里? HOT 4
- ER的两点疑问 HOT 11
- er/controller forwardaction 并不能阻止后续load行为 HOT 1
- locator中updateURL函数为啥还要比较一次getLocation() !== url HOT 1
- er在ie6,7,8里哪些功能不能用? HOT 2
- 有什么地方可以设置所有的action在complete的时候执行同一个方法么? HOT 2
- [email protected] 与 [email protected] 兼容问题 HOT 3
- Model 中复制 datasource 有 bug
- er的默认路径可以默认不显示吗?
- events.js中有几个event的说明重复有误
- 貌似这里promise resolver里this指向全局,并没有绑定当前context是promise
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from er.