2015-05-07 30 views
1

我使用ExtJS 5.0.1创建了一个简单的Panel,但是不工作。每次我得到的错误SyntaxError: expected expression, got '}'ExtJS 5:SyntaxError:预期的表达式,使用Ext.panel.Panel得到'}'

 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 
     }); 
+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

项目要么是

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

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

例如:

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

否则,没有什么错在你的构造。

+0

谢谢,现在看来它的工作原理(我不能在我的div中渲染它,但是是另一个问题)。 –

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变量已声明,并且错误仅针对此面板。..!

+0

嗨,我为主题添加了'anchura'和'altura'变量。在我的代码中,items:的对象将是一个formPanel和另一个Panel,但现在我只使用两个字符串。我试着用你的代码,但仍然出现相同的错误。 –

+0

分配你的另一个formPanel到变量中,并像我更新的答案一样使用它。 –

相关问题