ExtJS 5: SyntaxError: expected expression, got '}' using Ext.panel.Panel

ExtJS 5: SyntaxError: expected expression, got '}' using Ext.panel.Panel

我使用 ExtJS 5.0.1 创建了一个简单的面板,但没有用。每次我收到错误 SyntaxError: expected expression, got '}'

        var anchura = windowWidth;
        anchura *= 0.970;
        anchura += 1;
        var altura = windowHeight;
        altura *= 0.98;

    panel = new Ext.panel.Panel({
            id:'ventana',
            autoScroll:true,
            height: altura,
            width: anchura,
            title: '&nbsp;<bean:message key="breadcrumbs.gestionInventarios.consultaMultiple" />',
            iconCls:'vDependencias',
            layout: 'border',
            closable: false,
            renderTo: 'contenedor',
            resizable: false,
            items: ['algo','otro algo'],
            frame: true
        });

试试这样的方法,

panel = new Ext.panel.Panel({
            id:'ventana',
            autoScroll:true,
            height: altura,
            width: anchura,
            title: '&nbsp;<bean:message key="breadcrumbs.gestionInventarios.consultaMultiple" />',
            iconCls:'vDependencias',
            layout: 'border',
            closable: false,
            renderTo: 'contenedor',
            resizable: false,
            items: [variabl1,variabl2 ],
            frame: true
        });

这可能是您问题的根本原因。

此外,请确保已声明 alturaanchura 变量,并且仅此面板出现错误..!

var panel= Ext.create('Ext.panel.Panel', {
     id:'ventana',
            autoScroll:true,
            height: altura,
            width: anchura,
            title: '&nbsp;<bean:message key="breadcrumbs.gestionInventarios.consultaMultiple" />',
            iconCls:'vDependencias',
            layout: 'border',
            closable: false,
            renderTo: 'contenedor',
            resizable: false,
            items: [{some type},{some type}],
            frame: true
 });

由于您使用的是默认面板,因此您没有正确定义项目。 请参阅此处的文档:http://docs.sencha.com/extjs/5.0/5.0.1-apidocs/#!/api/Ext.grid.Panel-cfg-items

项目应该是

a single item, or an array of child Components to be added to this container

。组件是对象而不是字符串。 您不能将字符串数组传递给项目。

示例:

items:[
   {xtype:'button'}, 
   {xtype:'textfield'}
]

否则,您的构造没有任何问题。