Loading

ExtJS - ExtJS最佳实践

更新记录
转载请注明出处:https://www.cnblogs.com/cqpanda/p/16583543.html
2022年8月14日发布。
2022年8月13日 从笔记迁移到博客。

ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.html

不要手动为组件设置Id配置项

在大型项目中,手动设置组件id配置项容易导致id重复问题
Id重复将导致不可预料的错误
并且手动分配id不便于管理组件

子组件存在相同配置,使用defaults为它们设置相同的配置

减少代码输入、提高可维护性
使用Ext.container.Viewport作为视图的最顶层容器并有且只有一个
注意:Classic包中为Ext.container.Viewport类型
注意:Modern包中为Ext.Viewport类型

使用特定的组件,而不是组合多个组件

比如可以直接使用Ext.form.Panel,而不是Ext.panel.Panel内嵌套Ext.panel.Form
这样可以便于管理以及减少内存占用,提高运行效率

创建自定义组件,销毁时记得销毁所有相关的引用

When creating our custom components, it's very important to remember that we need to destroy all our references and internal components that we have created. This way, we'll free memory

直接在组件上监听事件,然后通过e.eventTarget比对获得事件触发的真实元素

navigationEl.on('click', function(e){
    //使用e.getTarget确定监听的组件内部元素

}, {
    delegate: 'a'
});
posted @ 2022-08-14 07:23  重庆熊猫  阅读(300)  评论(0编辑  收藏  举报