[
登录
|
注册
]
反馈问题或提出建议
社区首页
新 闻
小 组
博 问
闪 存
空 间
好 友
网站首页
Ext 2.0
/
Ext.fly 怎么理解?
浏览:1274
2007-11-22 09:10
来自
craboYang
:
如题,还有Ext.Find, Ext.getCmp 之类, 尽管用着, 总担心性能。
有什么 Best Practise?
楼主
2个月前
t-mac.NET
:
在Ext的wiki中对Flyweight有一个简短的介绍,即‘Use sharing to support large numbers of fine-grained objects efficiently. ’,有个哥们不懂,到论坛上发问,下面就是Ext的核心developer的回答:
Ext.Element wraps a lot of functionality around DOM element/node, for example functions like hide, show, all animation stuff, dimensions getting and setting function and a lot more.
Ext.Element keeps reference to DOM element it is wrapped around in dom property. Once you have an Ext.Element (e.g. you call Ext.get('some-id') it is an instance of Element class and you can work with it as such.
Now, imagine that you need to hide 1000 DOM nodes, you call 1000 times Ext.get('some-one-of-1000-id').hide() so you create 1000 instances of Element just to call one function: hide.
Ext.fly is one instance of Ext.Element with "replaceable" DOM node it is wrapped around. If you call 1000 times Ext.fly('some-one-of-1000-id').hide() you 1000 times replace dom property of one instance of Ext.Element.
Result: higher performance, lower memory usage.
You only need to keep in mind that you cannot keep Element returned by Ext.fly for later use as it's dom will sooner or later gets replaced by another one.
回复
1楼
2个月前
Beginor
:
回答的不错, 受教了
回复
2楼
你还不是小组成员,
加入小组
以后才能发布新主题!
有不合适内容,建议去除
>
返回“Ext 2.0”
其他话题
用EXTJS做的后台管理框架
(火舞狂歌)
Ext + asp.net MVC + Linq to SQL
(木野狐(Neil Chen))
关于js中的资源释放
(t-mac.NET)
AJAX式多数据源及节点异步加载树_meetrice
(meetrice )
Ext 2.1 发布了
(Beginor)
jquery扩展同extjs的对比?
(艾面条)
visual studio 2008将发直接支持Ext的IntelliSense
(阿不)
ext js看起来好,但难学啊
(沛沛)
Ext.fly 怎么理解?
(craboYang)
新建了一个extjs群,欢迎加入
(t-mac.NET)
有没有人遇到过js定时器走着走着就慢了。
(阿不)
看了panel的那个例子,怎么放我自己的内容呢?
(红尘中迷茫)
1
16222