有没有办法将一个应用程序扩展到另一个 mdi 应用程序?例如。我有 3 个应用程序:“Transaction”、“SalesOrder”和“PurchaseOrder”我想通过在“SalesOrder”和“PurchaseOrder”中扩展它来重用“Transaction”。干净的方法是什么?
问问题
707 次
2 回答
1
您可以简单地定义一个application
具有特定名称的名称,然后extend
从中定义。
BaseApp.js
:
Ext.application({
name: 'BaseApp',
launch: function () {
alert("Base App Launch");
}
});
ChildApp.js
:
Ext.application({
//extend from base app
extend: 'BaseApp',
name: 'ChildApp',
launch: function () {
alert("Child App Launch");
}
});
于 2012-11-11T11:22:24.680 回答
0
是的,从 ExtJS 4.2 开始就有可能。
在http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.app.Application检查文档部分“从 Ext.app.Application 派生”
这是一个小例子:
Ext.define('Transaction.Application', {
extend: 'Ext.app.Application',
requires: [],
// application namespace
name: 'Transaction',
// name of the app instance in DOM (e.g. Transaction.instance)
//appProperty: 'instance',
// application folder
appFolder: '/js/Transaction',
autoCreateViewport: true,
controllers: [
],
views: [
],
launch: function() {
console.log('application started');
}
});
Ext.define('SalesOrder.Application', {
extend: 'Transaction.Application',
requires: [],
// application namespace
name: 'SalesOrder',
// application folder
appFolder: '/js/SalesOrder',
autoCreateViewport: false,
controllers: [
],
views: [
],
launch: function() {
Ext.create('Ext.container.Viewport');
this.callParent();
}
});
Ext.define('PurchaseOrder.Application', {
extend: 'Transaction.Application',
requires: [],
// application namespace
name: 'PurchaseOrder',
// application folder
appFolder: '/js/PurchaseOrder',
autoCreateViewport: false,
controllers: [
],
views: [
],
launch: function() {
Ext.create('Ext.container.Viewport');
this.callParent();
}
});
Ext.application('PurchaseOrder.Application');
// Then you can acces your application instance anywhere:
var app = PurchaseOrder.getApplication();
于 2013-10-13T08:23:32.807 回答