Ext JS 4.0.7 - TypeError: name is undefined
Ext JS 4.0.7 - TypeError: name is undefined
我使用过 Ext JS 6.0,现在我正在尝试让我的应用程序在 Ext JS 4.0.7 中工作。版本 4 中可能存在语法错误,在版本 6 中是格式正确的代码,我没有发现,但我终究无法弄清楚它是什么。
引用商店和模型没有问题,但像这样加载自定义 xtype...
app/view/Main.js
Ext.define('App.view.Main', {
extend: 'Ext.container.Viewport',
title: 'App Title',
layout: 'anchor',
items: [
{
xtype: 'configurations',
itemId: 'configurationsSidebar'
}
]
});
app/view/leftSidebar/Configurations.js
Ext.define('App.view.leftSidebar.Configurations', {
extend: 'Ext.Panel',
alias: 'widget.configurations',
title: 'Configuration',
width: 250,
minWidth: 250,
split: true,
collapsible: true,
scrollable: true,
layout: 'anchor',
items: [
{
xtype: 'label',
text: 'Hi! You can see me'
}
]
});
导致我的控制台出现此错误(第一个是警告,第二个是错误):
Empty string passed to getElementById(). ext-all-debug-w-comments.js:8370:33
TypeError: name is undefined ext-all-debug-w-comments.js:8231:1
如有任何帮助,我们将不胜感激。
小部件名称无助于找到 JavaScript 文件,因此无法仅通过该名称加载它。您必须将组件的限定名称添加到父组件的 requires
列表中,如下所示:
Ext.define('App.view.Main', {
requires:['App.view.leftSidebar.Configurations']
这将导致加载子组件并注册 xtype
。
我使用过 Ext JS 6.0,现在我正在尝试让我的应用程序在 Ext JS 4.0.7 中工作。版本 4 中可能存在语法错误,在版本 6 中是格式正确的代码,我没有发现,但我终究无法弄清楚它是什么。
引用商店和模型没有问题,但像这样加载自定义 xtype...
app/view/Main.js
Ext.define('App.view.Main', {
extend: 'Ext.container.Viewport',
title: 'App Title',
layout: 'anchor',
items: [
{
xtype: 'configurations',
itemId: 'configurationsSidebar'
}
]
});
app/view/leftSidebar/Configurations.js
Ext.define('App.view.leftSidebar.Configurations', {
extend: 'Ext.Panel',
alias: 'widget.configurations',
title: 'Configuration',
width: 250,
minWidth: 250,
split: true,
collapsible: true,
scrollable: true,
layout: 'anchor',
items: [
{
xtype: 'label',
text: 'Hi! You can see me'
}
]
});
导致我的控制台出现此错误(第一个是警告,第二个是错误):
Empty string passed to getElementById(). ext-all-debug-w-comments.js:8370:33
TypeError: name is undefined ext-all-debug-w-comments.js:8231:1
如有任何帮助,我们将不胜感激。
小部件名称无助于找到 JavaScript 文件,因此无法仅通过该名称加载它。您必须将组件的限定名称添加到父组件的 requires
列表中,如下所示:
Ext.define('App.view.Main', {
requires:['App.view.leftSidebar.Configurations']
这将导致加载子组件并注册 xtype
。