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

查看:23
本文介绍了在 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/');

然后在定义公共组件时为它们提供相同的命名空间,并将它们放置在 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'
});

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

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