2012-05-22 23 views
0

我试图定义一个看法,但我得到一个错误在ExtJS中定义视图。 “遗漏的类型错误:无法调用未定义的方法‘子’”

Uncaught TypeError: Cannot call method 'substring' of undefined

/app/view/Sidebar.js

Ext.define('SimpleTodo.view.Sidebar', { 
    extend: 'Ext.panel.Panel', 
    alias: 'widget.sidebar', 
    config: { 
     title: 'Projects & Todo Lists', 
     tbar: [ 
      { 
       xtype: 'button', 
       text: 'Add Project' 
      }, 
      { 
       xtype: 'button', 
       text: 'Add Todo List' 
      } 
     ], 
     //store: Ext.data.StoreManager.lookup('projects'), 
     html: 'Hello world', 
     width: 200 
    } 
}); 

然后试图使用它我app.js

Ext.application({ 
    name: 'SimpleTodo', 
    views: [ 
     'Sidebar' 
    ], 
    appFolder: 'app', 
    launch: function() { 
     Ext.create('Ext.container.Viewport', { 
      layout: { 
       type: 'hbox', 
       pack: 'start', 
       align: 'stretch' 
      }, 
      items: [ 
       { 
        xtype: 'sidebar' // <---- here 
       }, 
       { 
        xtype: 'panel', 
        id: 'detailsView', 
        flex: 1, 
        layout: 'card', 
        items: [ 
         { 
          xtype: 'panel', 
          id: 'todoDetails', 
          title: 'Todo Details' 
         }, 
         { 
          xtype: 'panel', 
          id: 'addProject', 
          title: 'Add project', 
         } 
        ] 
       } 
      ] 
     }) 
    } 
}); 

我在想什么?我是否定义了我的观点并正确使用了它?

+0

如果你看一下网知识交通 - 你看到你的视图文件得到加载与否? – sha

+0

@sha,模型和商店正在加载,但不是查看 – jm2

+0

如何添加 '要求:['SimpleTodo.view.Sidebar']' – XenoN

回答

1

实际上,它必须是这样的:

Ext.application({ 
     name: 'SimpleTodo', 
     requires:[ 
     'SimpleTodo.view.Sidebar' 
     ], 
     appFolder: 'app', 
     launch: function() { 
      Ext.onReady(function(){ 
      Ext.create('Ext.container.Viewport', { 
       layout: { 
        type: 'hbox', 
        pack: 'start', 
        align: 'stretch' 
       }, 
       items: [ 
        { 
         xtype: 'sidebar' // <---- here 
        }, 
        { 
         xtype: 'panel', 
         id: 'detailsView', 
         flex: 1, 
         layout: 'card', 
         items: [ 
          { 
           xtype: 'panel', 
           id: 'todoDetails', 
           title: 'Todo Details' 
          }, 
          { 
           xtype: 'panel', 
           id: 'addProject', 
           title: 'Add project', 
          } 
         ] 
        } 
       ] 
      }) 
     }); 
     } 
    }); 
+0

为什么它不像控制器,模型和商店? – jm2

+0

它也可以是 意见:['边栏'] 直到您的视口或用户界面部分使用Ext.onReady它不会工作。我不确定,但看起来如果我们不使用onready,之前需要启动方法调用。还有 的意见,控制器,型号,商店 属性也有要求相同的作用。它会为它们生成getter setter方法。 – XenoN

+0

btw英语不是我的母语;)。对不起,我的英语不好。 – XenoN

相关问题