ExtJS 5:SyntaxError:期望的表达式,得到了'}'使用Ext.panel.Panel

时间:2015-05-07 11:29:33

标签: javascript extjs extjs5

我使用ExtJS 5.0.1创建了一个简单的Panel,但是不行。每次我收到错误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
        });

2 个答案:

答案 0 :(得分:0)

尝试这样的事情,

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变量,并且此面板只会出现错误..!

答案 1 :(得分:0)

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

项目应该是

  

要添加到其中的单个项目或子组件数组   容器

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

示例:

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

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