Under ExtJS 4 is there a way to load external components?

馋奶兔 提交于 2019-12-21 18:44:11

问题


I am trying to set up my ExtJS 4 project so I have three top level applications, for example,

/foo/app.js
/bar/app.js
/baz/app.js

Each 'top level' application is a separate ExtJS application, each with their own loaders. There are some cases were I will have general components that I want to share between all three applications, so I have /components top level directory.

If I have a component name say ComponentA,

/components/componenta.js

How would I go about getting ComponentA into all three applications, so it could referenced or extended by the individual application?


回答1:


You can add this same loader into each of the applications app.js file.

Ext.Loader.setPath('Common', '../components/');

Then give your common components the same namespace when you define them and place them in the components top level folder.

componenta.js

Ext.define('Common.componenta', {
    extend: 'Ext.panel.Panel',
    title: 'Component A'
});

Then the Common namespace will be available for you to extend in each application

Ext.define('Foo.panel', {
    extend: 'Common.componenta',
    title: 'Foo Panel'
});


来源:https://stackoverflow.com/questions/12185027/under-extjs-4-is-there-a-way-to-load-external-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!