如果你的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. OpenSessionInViewFilter与org.springframework.dao.InvalidDataAccessApiUsageException

    报错:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in r ...

  2. 《C和指针》读书笔记——第二章 基本概念

    1.编译过程: source code→Compiler→Object code→Linker←Lib ↓ Exe 2.经过初始化的静态变量(static)在程序执行前能获得他们的值. 3.绝大多数环 ...

  3. Vijos p1002 过河 离散化距离+区间DP

    链接:https://vijos.org/p/1002 题意:一条长度为L(L <= 1e9)的桥上有N(1<= N <= 100)颗石头.桥的起点为0终点为L.一只青蛙从0开始跳, ...

  4. SD卡FAT32文件系统格式

    一.声明 1.本文来源和主旨 2.本文测试环境 二.SD卡FAT文件系统 1.SD卡FAT32文件系统的整体布局 2.FAT文件系统简介 ① 文件分配表 ② 目录项 三.DBR(DOS BOOT RE ...

  5. Oracle删除表、字段之前判断表、字段是否存在

    这篇文章主要介绍了Oracle删除表.字段之前判断表.字段是否存在的相关资料,需要的朋友可以参考下 在Oracle中若删除一个不存在的表,如 “DROP TABLE tableName”,则会提示: ...

  6. 推荐一本书《深入理解PHP内核》

    <深入理解PHP内核> 在线网址:http://www.php-internals.com/

  7. 3.5MM/2.5MM耳机插头定义

    自2009年国内手机耳机接口统一以来,现在国内销售耳机基本就3.5MM和2.5MM两种,当然也有很少BT厂家,就是不用这两种,比如使用MiniUSB等接口作为耳机接口.3.5mm耳机插头按照结构划分, ...

  8. QStringRef可以提高性能,下次注意使用;QPair方便了语法,函数可以一次返回多个返回值,方便使用

    而且QPair从此与各种QMap容器联系了起来,会非常好用.甚至QList也可以成双成对的使用元素了: QList<QPair<int, double> > list;list ...

  9. VIM 及其插件使用快捷键汇总

    我的博客:www.while0.com vim搜索取消高亮 :nohl

  10. 学习笔记-[Maven实战]-第三章:Maven使用入门(1)

    说明:[Maven实战]一书还介绍了怎么样手工创建Maven工程,学习这本书是为了能尽快在工作中使用,就忽略了手工建工程的部分 如果想了解这部分的内容,可以自己看看书 开始: 1.新建一个maven工 ...