这问题搞了我几天了,实在没办法了,下面的代码,如果引入ext-all-debug就不报错,但是没显示,如果去掉果个JS,就报:
Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: widget.LinksPanel
哪位高人可以帮我看一下,谢谢!Ext.ns('Example');
Ext.define('MyApp.LinksPanel', {
extend: 'Ext.panel.Panel',
split: false,
collapsible: true
,
cls: 'link-panel'
,
links: [{
text: 'Link 1'
,
href: '#' },
{
text: 'Link 2'
,
href: '#' },
{
text: 'Link 3'
,
href: '#' }]
,
layout: 'fit'
,
tpl: new Ext.XTemplate('<tpl for="links"><a class="examplelink" href="{href}">{text}</a></tpl>')
,
afterRender: function() {
this.superclass.afterRender.apply(this, arguments);
this.tpl.overwrite(this.body, {
links: this.links });
}
});Example.Window = Ext.define('Myapp.view', {
extend: 'Ext.Viewport',
alias: 'widget.examplewindow',
initComponent: function() {
var config = {
items: [{
xtype: 'LinksPanel',
margins: '5 5 5 5',
split: true,
layout: 'accordion',
layoutConfig: {
animate: true },
width: 250,
minWidth: 100,
region: "west" },
{
title: "面板",
region: "north",
height: 100,
html: "<h1>DMS项目管理系统!</h1>" },
{
xtype: "tabpanel",
region: "center",
margins: '5 0 0 0',
items: [{
title: "面板一" },
{
title: "面板二" }] }] };
Ext.apply(this, Ext.apply(this.initialConfig, config));
this.superclass.initComponent.apply(this, arguments);
this.linksPanel = this.items.itemAt(0);
this.tabPanel = this.items.itemAt(1);
this.linksPanel.on({
scope: this
,
render: function() {
this.linksPanel.body.on({
scope: this
,
click: this.onLinkClick
,
delegate: 'a.examplelink'
,
stopEvent: true
}); } }); },
onLinkClick: function(e, t) {
var title = t.innerHTML;
var tab = this.tabPanel.items.find(function(i) {
return i.title === title; });
if (!tab) {
tab = this.tabPanel.add({
title: title
,
layout: 'fit' }); }
this.tabPanel.setActiveTab(tab); }
})Ext.onReady(function() {
var win = new Example.Window({
width: 600
,
height: 400
,
closable: false
,
title: Ext.fly('page-title').dom.innerHTML
});
win.show();});
Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: widget.LinksPanel
哪位高人可以帮我看一下,谢谢!Ext.ns('Example');
Ext.define('MyApp.LinksPanel', {
extend: 'Ext.panel.Panel',
split: false,
collapsible: true
,
cls: 'link-panel'
,
links: [{
text: 'Link 1'
,
href: '#' },
{
text: 'Link 2'
,
href: '#' },
{
text: 'Link 3'
,
href: '#' }]
,
layout: 'fit'
,
tpl: new Ext.XTemplate('<tpl for="links"><a class="examplelink" href="{href}">{text}</a></tpl>')
,
afterRender: function() {
this.superclass.afterRender.apply(this, arguments);
this.tpl.overwrite(this.body, {
links: this.links });
}
});Example.Window = Ext.define('Myapp.view', {
extend: 'Ext.Viewport',
alias: 'widget.examplewindow',
initComponent: function() {
var config = {
items: [{
xtype: 'LinksPanel',
margins: '5 5 5 5',
split: true,
layout: 'accordion',
layoutConfig: {
animate: true },
width: 250,
minWidth: 100,
region: "west" },
{
title: "面板",
region: "north",
height: 100,
html: "<h1>DMS项目管理系统!</h1>" },
{
xtype: "tabpanel",
region: "center",
margins: '5 0 0 0',
items: [{
title: "面板一" },
{
title: "面板二" }] }] };
Ext.apply(this, Ext.apply(this.initialConfig, config));
this.superclass.initComponent.apply(this, arguments);
this.linksPanel = this.items.itemAt(0);
this.tabPanel = this.items.itemAt(1);
this.linksPanel.on({
scope: this
,
render: function() {
this.linksPanel.body.on({
scope: this
,
click: this.onLinkClick
,
delegate: 'a.examplelink'
,
stopEvent: true
}); } }); },
onLinkClick: function(e, t) {
var title = t.innerHTML;
var tab = this.tabPanel.items.find(function(i) {
return i.title === title; });
if (!tab) {
tab = this.tabPanel.add({
title: title
,
layout: 'fit' }); }
this.tabPanel.setActiveTab(tab); }
})Ext.onReady(function() {
var win = new Example.Window({
width: 600
,
height: 400
,
closable: false
,
title: Ext.fly('page-title').dom.innerHTML
});
win.show();});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货