我有一个ExtJS数据存储,可以向服务器查询数据。我可以在Chrome网络响应标签中看到JSON数据,但是当我使用Ext.getStore("ExampleStore").data.length
在控制台选项卡中检查商店的大小时,该值始终为零。页面上未报告任何Javascript错误。有没有更好的方法来调试加载到商店的数据?
答案 0 :(得分:2)
您可以在ExtJS 1.1.0及更高版本中的商店load
事件和ExtJS 3.4.0及更高版本中的代理exception
事件上附加事件回调。对于旧版本的ExtJS回到1.1.0,您可以使用商店的loadexception
事件。从任何一个回调中,很容易找到一个断点并弄清楚发生了什么。
Ext.create("Ext.data.Store", {
storeId: "ExampleStore"
// Other properties removed for brevity
}).on({
load: function(store, records, successful, eOpts) {
alert("The load event was called");
},
exception: function(proxy, response, operation, eOpts) {
alert("The exception event was called");
}
});
答案 1 :(得分:0)
我强烈建议您使用Fire Bug for Fire Fox
https://addons.mozilla.org/es/firefox/addon/firebug/
在我看来,它提供了有关错误和更好格式化的更多信息,我喜欢在Chrome中测试('它更快)但是当我收到错误时我无法理解我跑到FireBug
您可以执行console.log(myStore);
并从那里探索对象的DOM
另请参阅存储方法,如getCount和getTotalCount
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store
祝你好运
答案 2 :(得分:0)
我不确定如何将ExtJS实现到您的应用程序中,但对于上述所有内容,我可以添加您可以用来调试文件ext-all-debug-w-comments:
<script type="text/javascript" src="../ext-all-debug-w-comments.js"></ script>
这将使控制台中显示的错误报告更加丰富。