如果你的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. IIS 10.0 无法安装 URL rewrite重写模块 2.0

    打开注册表编辑器,在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp位置 把MajorVersion的值改为9之后,就可以安装了,安装完成之后,再把Major ...

  2. hdu 1568 Fibonacci 数学公式

    Fibonacci Problem Description 2007年到来了.经过2006年一年的修炼,数学神童zouyu终于把0到的Fibonacci数列(f[0]=0,f[1]=1;f[i] = ...

  3. 自定义一个"花瓣"菜单-b

    先来看一下效果 XLCircleMenu.gif 是不是觉得挺好玩的呀. 通过这篇文章你可以学到: 1.系统UITableView的部分设计思想 2.自定义控件常用设计思路 3.动画的具体使用 4.手 ...

  4. 关于 js 2个数组取差集怎么取

    关于 js 2个数组取差集怎么取? 例如求var arr1 = [1]; var arr2 = [1,2];的差集方法一: Array.prototype.diff = function(a) { r ...

  5. android apk 反编译

    Apk文件结构 apk文件实际是一个zip压缩包,可以通过解压缩工具解开.以下是我们用zip解开helloworld.apk文件后看到的内容.可以看到其结构跟新建立的工程结构有些类似. java代码: ...

  6. apache+tomcat 负载均衡

    说明:本篇不面向无开发基础的人员,所以不会有软件下载,jdk安装等步骤.比较久远的东西了...... 1.系统环境 win7-64.jdk 2.软件列表: apache_2.2.24-x64-no-s ...

  7. delphi xe5 android 开发数据访问手机端 解决乱码的办法

    经过测试,将sqlserver里的字段由varchar 或者char  改为  nvarchar 或者nchar 然后在手机端的clientdataset 增加字段的时候数据类型选择widestrin ...

  8. csuoj 1352: New Sorting Algorithm

    因为每个元素都是移动到比它小1位的元素的后面: 这样的话以后的一定就可以把他们两个打包: 所以用这种方法最多扫一遍就可以了: 但是最小的那个数要不要移动呢? 如果最小的数后面的数都是升序的,那么一直扫 ...

  9. System.out.println(对象)

    class Person { private String name; private int age; public String getName() { return this.name; } p ...

  10. Android Binder设计与实现 - 设计篇

    要 Binder是Android系统进程间通信(IPC)方式之一.Linux已经拥有管道,system V IPC,socket等IPC手段,却还要倚赖Binder来实现进程间通信,说明Binder具 ...