如果你的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. log4j记录运行日志

    1.在工程中导入log4j-1.2.15.jar的jar包2.新建测试类 package control; import org.apache.log4j.Logger; import org.apa ...

  2. java项目使用的DBhelper类

    import java.io.*; import java.sql.*; import java.util.*; import javax.servlet.jsp.jstl.sql.*; public ...

  3. hdu 2087 剪花布条 KMP多次匹配

    剪花布条 Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?   I ...

  4. HIVE中内连接和左半连接不一致问题

    一.理论 HIVE中都是按等值连接来统计的,理论上两种写法统计结果应该是一致的: 二.实际情况 但实际使用中发现两种写法会返回的结果,总会有一些差距虽然差别不大,但让人很是困惑. 三.原因 当使用jo ...

  5. 关于博客名“大话济公”的说明

    其实本来没打算起这个名字的,换了几个名字都被占用了(无语啊...).最近呢,我在研究<济公传>,对于济公的传说比较喜欢,尤其是这个任务,诙谐幽默,同时有时时刻刻在帮助有困难的群众,虽然是个 ...

  6. COOKIE漫谈

    cookie概述在上一节,曾经利用一个不变的框架来存储购物栏数据,而商品显示页面是不断变化的,尽管这样能达到一个模拟全局变量的功能,但并不严谨.例如在导航框架页面内右击,单击快捷菜单中的[刷新]命令, ...

  7. BIOS与CMOS有什么区别

    本文介绍BIOS与CMOS区别,BIOS是什么?BIOS全称Basic Input/Output System,所以BIOS本身个是系统简称,所以我们常说的BIOS芯片确切的讲是写有BIOS系统的芯片 ...

  8. 中国版dropbox“坚果云”和它背后的团队故事(大的优势就在于他为用户提供了设定多个文件夹的权利)

    (速途网专栏 作者:娄昊川)坚果云是一款中文存储服务,前身是“坚果铺子”,提供免费的云空间,与dropbox类似,用户可以直接把档案同步到坚果云,供自己和伙伴用任何设备访问.自上线以来,几乎所有用户都 ...

  9. Web Service学习笔记(webservice、soap、wsdl、jws详细分析)

    Web Service概述 Web Service的定义 W3C组织对其的定义如下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的API ...

  10. 【HDOJ】1033 Edge

    题目英文太多,简单翻译了一下:1. For products that are wrapped in small packings it is necessary that the sheet of ...