在ExtJS 4下有一种加载外部组件的方法? [英] Under ExtJS 4 is there a way to load external components?

查看:126
本文介绍了在ExtJS 4下有一种加载外部组件的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置我的ExtJS 4项目,所以我有三个顶级应用程序,例如,

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

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

每个顶级应用程序是一个单独的ExtJS应用程序,每个应用程序都有自己的装载程序。在某些情况下,我将有一些组件,我想在所有三个应用程序之间共享,所以我有 / components 顶级目录。

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.

如果我有一个组件名称说ComponentA,

If I have a component name say ComponentA,


/components/componenta.js

/components/componenta.js

我将如何将ComponentA转换为所有三个应用程序,因此可以由单个应用程序引用或扩展?

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

推荐答案

您可以将这个相同的加载程序添加到每个应用程序 app.js 文件中。

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

componenta.js

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

然后,Common命名空间将可用于在每个应用程序中扩展

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

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

这篇关于在ExtJS 4下有一种加载外部组件的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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