如果你的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. 上传头像,界面无跳转,php+js

    上传头像,界面无跳转的方式很多,我用的是加个iframe那种.下面直接上代码. html: //route 为后端接口//upload/avatar 为上传的头像的保存地址//imgurl=/uplo ...

  2. PHPCMS如何实现后台访问限制?

    修改phpcms 后台管理路径,可以有效的防止因为程序漏洞,或者是服务器安全问题所带来的 phpcms系统管理权限被黑客获取 文件路径:/caches/config/system.php 修改:'ad ...

  3. FolderBrowserDialog组件选择文件夹

    1.选择路径 this.folderBrowserDialog1.ShowDialog(); if (this.folderBrowserDialog1.ShowDialog() == DialogR ...

  4. CODEVS 1067 机器翻译

    题目描述 Description 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义 来替换.对于每个英 ...

  5. Android 绘制计时器

    用小米的手机,发现其实还可以,无意间点开小米的计时器,发现界面非常好看和实用.于是自己仿照着写一个,由于技术不好,代码整体结构上可能有点乱,但主要的实现功能和掌握知识点. Android中绘制采用ca ...

  6. MyEclipse使用自己的JDK和Tomcat

    配置tomcat:window-->preferences-->myeclipse-->servers-->tomcat-->选一个-->右边选择一的tomcat的 ...

  7. 解决Ubuntu root账户的问题

    问题的提出:在Linux环境下,许多操作需要有管理员权限才能进行.如果没有root权限,就连基本的文件拷贝操作都只能在用户文件夹下进行,而对于Ubuntu系统,安装时是没有设定root帐号的,那么怎样 ...

  8. [jobdu]二叉树的镜像

    树的镜像,这里的做法就是先序遍历的反过来呗. #include <iostream> #include <vector> using namespace std; void p ...

  9. Postman(API & HTTP请求调试插件)和Apizza fiddler

    http://blog.csdn.net/u011012932/article/details/51456263#comments

  10. 分析Java的类加载器与ClassLoader(二):classpath与查找类字节码的顺序,分析ExtClassLoader与AppClassLoader的源码

    先回顾一下classpath classpath的作用: classpath的作用是指定查找类的路径:当使用java命令执行一个类(类中的main方法)时,会从classpath中进行查找这个类. 指 ...