2015-05-07 27 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到變量中,並像我更新的答案一樣使用它。 –

相關問題