Extjs 我们如何覆盖分机基地?
我使用的是ExtJSV7.1,我已经覆盖了Ext.Base,为从Ext.Base继承的类设置了命名方案:这简化了调试Extjs 我们如何覆盖分机基地?,extjs,extjs7,Extjs,Extjs7,我使用的是ExtJSV7.1,我已经覆盖了Ext.Base,为从Ext.Base继承的类设置了命名方案:这简化了调试 Ext.define('App.class.Base', { override: 'Ext.Base', constructor: function() { var me = this /** * App.base.store.Base => store-base- * App.store.Menu => store-m
Ext.define('App.class.Base', {
override: 'Ext.Base',
constructor: function() {
var me = this
/**
* App.base.store.Base => store-base-
* App.store.Menu => store-menu-
*/
if (me.isIdentifiable) {
if (!me.self.prototype.hasOwnProperty('identifiablePrefix')) {
const classNameParts = me.$className.match(/([^\.]+)/g)
if (classNameParts && classNameParts[0] === 'App') {
classNameParts.splice(0, classNameParts.length - 2)
me.self.prototype.identifiablePrefix = classNameParts.reduce((i, j) => i + '-' + j).toLocaleLowerCase() + '-'
}
}
}
return me.callParent()
}
})
此代码以前生成时没有错误,但在我将Sencha Cmd升级到v7.3.0.19之后,我启动了获取以下错误的程序:
[ERR] C2016: Override target not found -- /...../packages/local/module-core/overrides/class/Base.js:2:64
[WRN] Override App.class.Base in file /..../packages/local/module-core/overrides/class/Base.js had no target detected
我不知道这是否是执行此覆盖的正确位置/方式,如果不是,我可以更改我的实现。但是,如果没有其他方法,如何消除构建错误
提前感谢,
Ipek因为我不再使用sencha构建工具,我无法直接帮助您,但我想分享另一种方法: 如果您首先加载了框架ext debug all或ext all等,并且应该被覆盖的类已经定义,您可以这样做:
Ext.Component.override({
initComponent: function () {
Ext.log('bootstraping ' + this.self.getName());
var me = this,
width = me.width,
height = me.height;
// If plugins have been added by a subclass's initComponent before calling up to here (or any components
// that don't have a table view), the processed flag will not have been set, and we must process them again.
// We could just call getPlugins here however most components don't have them so prevent the extra function call.
if (me.plugins && !me.plugins.processed) {
me.plugins = me.constructPlugins();
}
me.pluginsInitialized = true;
// this will properly (ignore or) constrain the configured width/height to their
// min/max values for consistency.
if (width != null || height != null) {
me.setSize(width, height);
}
if (me.listeners) {
me.on(me.listeners);
me.listeners = null; //change the value to remove any on prototype
}
if (me.focusable) {
me.initFocusable();
}
}
});
Ext.Base.override({
constructor: function() {
var me = this
/**
* App.base.store.Base => store-base-
* App.store.Menu => store-menu-
*/
if (me.isIdentifiable) {
if (!me.self.prototype.hasOwnProperty('identifiablePrefix')) {
const classNameParts = me.$className.match(/([^\.]+)/g)
if (classNameParts && classNameParts[0] === 'App') {
classNameParts.splice(0, classNameParts.length - 2)
me.self.prototype.identifiablePrefix = classNameParts.reduce((i, j) => i + '-' + j).toLocaleLowerCase() + '-'
}
}else{
console.log('isIdentifiable');
console.log(me.identifiablePrefix);
}
}
return me.callParent(arguments)
}
});
根据进一步的内部处理,您可以调用callParent或callSuper。
详情如下:
您可以将上面的代码移到函数中,稍后再调用它,例如,当Ext.isReady时。我想这可以解决或解决您所面临的一些开放工具问题
更新:
回到您的问题,您可以执行以下操作并这样定义:
Ext.Component.override({
initComponent: function () {
Ext.log('bootstraping ' + this.self.getName());
var me = this,
width = me.width,
height = me.height;
// If plugins have been added by a subclass's initComponent before calling up to here (or any components
// that don't have a table view), the processed flag will not have been set, and we must process them again.
// We could just call getPlugins here however most components don't have them so prevent the extra function call.
if (me.plugins && !me.plugins.processed) {
me.plugins = me.constructPlugins();
}
me.pluginsInitialized = true;
// this will properly (ignore or) constrain the configured width/height to their
// min/max values for consistency.
if (width != null || height != null) {
me.setSize(width, height);
}
if (me.listeners) {
me.on(me.listeners);
me.listeners = null; //change the value to remove any on prototype
}
if (me.focusable) {
me.initFocusable();
}
}
});
Ext.Base.override({
constructor: function() {
var me = this
/**
* App.base.store.Base => store-base-
* App.store.Menu => store-menu-
*/
if (me.isIdentifiable) {
if (!me.self.prototype.hasOwnProperty('identifiablePrefix')) {
const classNameParts = me.$className.match(/([^\.]+)/g)
if (classNameParts && classNameParts[0] === 'App') {
classNameParts.splice(0, classNameParts.length - 2)
me.self.prototype.identifiablePrefix = classNameParts.reduce((i, j) => i + '-' + j).toLocaleLowerCase() + '-'
}
}else{
console.log('isIdentifiable');
console.log(me.identifiablePrefix);
}
}
return me.callParent(arguments)
}
});
我在这里加了一把放大小提琴。如果设置了identifiablePrefix,它应该记录helloWorld
由于我不再使用sencha构建工具,我无法直接帮助您,但我想与您分享另一种方法: 如果您首先加载了框架ext debug all或ext all等,并且应该被覆盖的类已经定义,您可以这样做:
Ext.Component.override({
initComponent: function () {
Ext.log('bootstraping ' + this.self.getName());
var me = this,
width = me.width,
height = me.height;
// If plugins have been added by a subclass's initComponent before calling up to here (or any components
// that don't have a table view), the processed flag will not have been set, and we must process them again.
// We could just call getPlugins here however most components don't have them so prevent the extra function call.
if (me.plugins && !me.plugins.processed) {
me.plugins = me.constructPlugins();
}
me.pluginsInitialized = true;
// this will properly (ignore or) constrain the configured width/height to their
// min/max values for consistency.
if (width != null || height != null) {
me.setSize(width, height);
}
if (me.listeners) {
me.on(me.listeners);
me.listeners = null; //change the value to remove any on prototype
}
if (me.focusable) {
me.initFocusable();
}
}
});
Ext.Base.override({
constructor: function() {
var me = this
/**
* App.base.store.Base => store-base-
* App.store.Menu => store-menu-
*/
if (me.isIdentifiable) {
if (!me.self.prototype.hasOwnProperty('identifiablePrefix')) {
const classNameParts = me.$className.match(/([^\.]+)/g)
if (classNameParts && classNameParts[0] === 'App') {
classNameParts.splice(0, classNameParts.length - 2)
me.self.prototype.identifiablePrefix = classNameParts.reduce((i, j) => i + '-' + j).toLocaleLowerCase() + '-'
}
}else{
console.log('isIdentifiable');
console.log(me.identifiablePrefix);
}
}
return me.callParent(arguments)
}
});
根据进一步的内部处理,您可以调用callParent或callSuper。
详情如下:
您可以将上面的代码移到函数中,稍后再调用它,例如,当Ext.isReady时。我想这可以解决或解决您所面临的一些开放工具问题
更新:
回到您的问题,您可以执行以下操作并这样定义:
Ext.Component.override({
initComponent: function () {
Ext.log('bootstraping ' + this.self.getName());
var me = this,
width = me.width,
height = me.height;
// If plugins have been added by a subclass's initComponent before calling up to here (or any components
// that don't have a table view), the processed flag will not have been set, and we must process them again.
// We could just call getPlugins here however most components don't have them so prevent the extra function call.
if (me.plugins && !me.plugins.processed) {
me.plugins = me.constructPlugins();
}
me.pluginsInitialized = true;
// this will properly (ignore or) constrain the configured width/height to their
// min/max values for consistency.
if (width != null || height != null) {
me.setSize(width, height);
}
if (me.listeners) {
me.on(me.listeners);
me.listeners = null; //change the value to remove any on prototype
}
if (me.focusable) {
me.initFocusable();
}
}
});
Ext.Base.override({
constructor: function() {
var me = this
/**
* App.base.store.Base => store-base-
* App.store.Menu => store-menu-
*/
if (me.isIdentifiable) {
if (!me.self.prototype.hasOwnProperty('identifiablePrefix')) {
const classNameParts = me.$className.match(/([^\.]+)/g)
if (classNameParts && classNameParts[0] === 'App') {
classNameParts.splice(0, classNameParts.length - 2)
me.self.prototype.identifiablePrefix = classNameParts.reduce((i, j) => i + '-' + j).toLocaleLowerCase() + '-'
}
}else{
console.log('isIdentifiable');
console.log(me.identifiablePrefix);
}
}
return me.callParent(arguments)
}
});
我在这里加了一把放大小提琴。如果设置了identifiablePrefix,它应该记录helloWorld
这个错误实际上并没有破坏你的构建,对吗?几个月前,我就这个问题打开了Sencha支持线程,支持工程师和我都得出结论,这个错误实际上不是一个错误,他们将降低它在OTOOLS-66票证中Sencha Cmd中的显示方式。感谢回复@incutonez。它确实破坏了构建,在它没有之前。实际上,它破坏了生产构建:sencha应用构建-生产-使用。但是,当我进行测试构建时,它既不会给出错误也不会给出警告。嗯,如果是这样的话,我会鼓励您创建Sencha支持票证,因为这似乎非常紧迫。感谢@incutonezWish的帮助,我真的可以帮上忙!当您从Sencha支持部门得到答案时,如果您能在这里添加答案,我们将不胜感激。但这个错误实际上并不会破坏您的构建,对吗?几个月前,我就这个问题打开了Sencha支持线程,支持工程师和我都得出结论,这个错误实际上不是一个错误,他们将降低它在OTOOLS-66票证中Sencha Cmd中的显示方式。感谢回复@incutonez。它确实破坏了构建,在它没有之前。实际上,它破坏了生产构建:sencha应用构建-生产-使用。但是,当我进行测试构建时,它既不会给出错误也不会给出警告。嗯,如果是这样的话,我会鼓励您创建Sencha支持票证,因为这似乎非常紧迫。感谢@incutonezWish的帮助,我真的可以帮上忙!当您从Sencha Support获得答案时,如果您能在此处添加答案,将不胜感激。