如果你的EXTJS报错: Cannot read property 'dom' of null,那就有可能是因为你的HTML或者JSP文件中的BODY标签里面少了个东西比如代码是:

  1. <html>
  2. <head>
  3. <title>Hello Ext</title>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
  6. <script type="text/javascript" src="extjs/ext-all.js"></script>
  7. </head>
  8. <body >
  9. <div id="example-grid"></div>
  10. </body>
  11. </html>
  12. <script type="text/javascript">
  13. Ext.require([
  14. 'Ext.data.*',
  15. 'Ext.grid.*'
  16. ]);
  17. Ext.onReady(function(){
  18. Ext.define('Book',{
  19. extend: 'Ext.data.Model',
  20. proxy: {
  21. type: 'ajax',
  22. reader: 'xml'
  23. },
  24. fields: [
  25. // set up the fields mapping into the xml doc
  26. // The first needs mapping, the others are very basic
  27. {name: 'Author', mapping: '@author.name'},
  28. 'Title', 'Manufacturer', 'ProductGroup'
  29. ]
  30. });
  31. // create the Data Store
  32. var store = Ext.create('Ext.data.Store', {
  33. model: 'Book',
  34. autoLoad: true,
  35. proxy: {
  36. // load using HTTP
  37. type: 'ajax',
  38. url: 'sampledata-sheldon.xml',
  39. // the return will be XML, so lets set up a reader
  40. reader: {
  41. type: 'xml',
  42. // records will have an "Item" tag
  43. record: 'Item',
  44. idProperty: 'ASIN',
  45. totalRecords: '@total'
  46. }
  47. }
  48. });
  49. // create the grid
  50. Ext.create('Ext.grid.Panel', {
  51. store: store,
  52. columns: [
  53. {text: "Author", flex: 1, dataIndex: 'Author'},
  54. {text: "Title", width: 180, dataIndex: 'Title'},
  55. {text: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
  56. {text: "Product Group", width: 100, dataIndex: 'ProductGroup'}
  57. ],
  58. renderTo:'example-grid',
  59. width: 540,
  60. height: 200
  61. });
  62. });
  63. </script>

如果这个代码里面没有id为'example-grid'的DIV的话会报错:Cannot read property 'dom' of null。加上后就不会报这样的错误了!

extjs Cannot read property 'dom' of null的更多相关文章

  1. Extjs4---Cannot read property 'addCls' of null - heirenheiren的专栏 - 博客频道 - CSDN.NET

    body { font-family: 微软雅黑,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLi ...

  2. js执行函数报错Cannot set property 'value' of null怎么解决?

    js执行函数报错Cannot set property 'value' of null 的解决方案: 原因:dom还没有完全加载 第一步:所以js建议放在body下面执行, 第二步:window.on ...

  3. JavaScript Uncaught TypeError: Cannot read property 'value' of null

    用 JavaScript 操作 DOM 时出现如下错误: Uncaught TypeError: Cannot set property 'value' of null Uncaught TypeEr ...

  4. 报错”Cannot read property 'addEventListener' of null“

    1.报错:Cannot read property 'addEventListener' of null 2.解决方案: 把代码放到window.onload=function(){...}里面,因为 ...

  5. Cannot read property 'nodeType' of null; audio元素默认样式下载按钮

    1.chrome-->console抛出如下错误: Uncaught TypeError: Cannot read property 'nodeType' of null 错误原因:从stack ...

  6. echarts js报错 Cannot read property 'getAttribute' of null

    本文将为您描述如何解决 eharts.js报错 Uncaught TypeError: Cannot read property 'getAttribute' of null 的问题 根据报错信息查找 ...

  7. 百度ueditor 实例化 Cannot set property 'innerHTML' of null 完美解决方案

    此时此刻,我正在用博客园推荐的TinyMCE编辑器写这个博客,突然想起最近在项目中使用百度ueditor编辑器中的一些经历.所以记录在此,与大家分享. 不得不说,百度ueditor是一款很好的在线编辑 ...

  8. org.hibernate.PropertyValueException: not-null property references a null or transient value:

    org.hibernate.PropertyValueException: not-null property references a null or transient value: com.bj ...

  9. Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null

    在开发Ext 项目中如果遇到 Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null 这个错误,检查下renderT ...

随机推荐

  1. 开发设计模式(六)多例模式(Multition Pattern)

    多例模式实际上就是单例模式的扩充,多例模式又划分为有上限多例模式和无上限多例模式两种,有上限多例模式中的多例类的实例是有上限的,当这个多例类中的上限数值上等于 1 时,此时,多例类退化回到了单例类:而 ...

  2. win7 64下暗黑世界V1.1 服务器端及客户端的安装及运行 成功

    原地址:http://bbs.gameres.com/thread_223717.html 屌丝一枚,没有MAC 更没有XCODE 潜心整了星期六与星期天两天才安装运行成功...只能说安装太复杂了,, ...

  3. su: /bin/bash: Permission denied

    https://bbs.archlinux.org/viewtopic.php?id=105541 New user created as: groupadd mygroupuseradd -s /b ...

  4. apk签名《转》

    出处!:http://jeff-pluto-1874.iteye.com/blog/847366 我觉得写的不错就转载了. 一.Android Apk签名Apk签名首先要有一个keystore的签名用 ...

  5. easyui源码翻译1.32--ComboTree(树形下拉框)

    前言 扩展自$.fn.combo.defaults和$.fn.tree.defaults.使用$.fn.combotree.defaults重写默认值对象.下载该插件翻译源码 树形下拉框结合选择控件和 ...

  6. [jobdu]数组中出现次数超过一半的数字

    找到以后要再扫一遍确认. http://zhedahht.blog.163.com/blog/static/25411174201085114733349/ #include <iostream ...

  7. ANDROID_MARS学习笔记_S01原始版_009_SQLite

    一.代码1.xml(1)activity_main.xml <?xml version="1.0" encoding="utf-8"?> <L ...

  8. MinGW 编译libwebsockets

    libwebsockets是一个轻量的纯C库,在这里尝试使用MinGW进行构建. 官网地址:http://libwebsockets.org/trac/libwebsockets下载地址:http:/ ...

  9. Native Application 开发详解(直接在程序中调用 ntdll.dll 中的 Native API,有内存小、速度快、安全、API丰富等8大优点)

    文章目录:                   1. 引子: 2. Native Application Demo 展示: 3. Native Application 简介: 4. Native Ap ...

  10. Android 应用程序窗口化

    Android 应用程序窗口化与 Store 应用程序窗口化-Android,Windows,better,chrome,archon-远景-Win8|Win8.1|Windows8.1|Win10| ...