我是extjs.的新手。我试着用MVC架构编写一个简单的应用程序,如下所述: http://docs-origin.sencha.com/extjs/4.2.1
当我尝试在浏览器中运行应用程序时,我在firebug中提出了这个错误:
"NetworkError: 404 Not Found - http://127.0.0.1/Sample/app/view/userlist.js?_dc=1408194279243"
我的项目结构是:
List.js文件:
/**
* Created by Sina-PC on 8/14/14.
*/
Ext.define('Sample.view.users.List' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
title: 'All Users',
initComponent: function() {
this.store = {
fields: ['name', 'email'],
data : [
{name: 'Ed', email: 'ed@sencha.com'},
{name: 'Tommy', email: 'tommy@sencha.com'}
]
};
this.columns = [
{header: 'Name', dataIndex: 'name', flex: 1},
{header: 'Email', dataIndex: 'email', flex: 1}
];
this.callParent(arguments);
}
});
Users.js文件:
Ext.define('Sample.controller.Users', {
extend: 'Ext.app.Controller',
views:['userlist'],
init: function() {
console.log('Initzed Users! This happens before the Application launch function is called');
this.control({
'viewport > panel': {
render: this.onPanelRendered
}
});
}
,
onPanelRendered: function() {
console.log('The panel was rendered');
}
});/**
* Created by Sina-PC on 8/14/14.
*/
app.js文件:
Ext.application({
name: 'Sample',
appFolder:'app',
controllers:[
'Users'
],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'userlist'
}
]
});
}
});
和index.html:
<html>
<head>
<title>Hello Ext</title>
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
<script type="text/javascript" src="extjs/ext-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>
答案 0 :(得分:0)
ExtJs不知道什么是视图'userlist'。您必须添加才需要此文件。
Ext.define('Sample.controller.Users', {
requires: [ 'Sample.view.users.List' ],
...
答案 1 :(得分:0)
Users.js文件有&#34;观看次数:[&#39;用户列表&#39;],&#34;应该是&#34;观点:[&#39; Sample.view.users.List&#39;],&#34;