<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XmlTreeLoader Example</title>
<link rel="stylesheet" type="text/css" href="Scripts/resources/css/ext-all.css" />
<script type="text/javascript" src="Scripts/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="Scripts/ext-all.js" ></script>
<script type="text/javascript">
var tree = new Ext.tree.TreePanel({
renderTo: "tree"
//root: new Ext.tree.TreeNode({ text: '我是根' })
});
var root = new Ext.tree.TreeNode({ text: '我是根' });
tree.setRootNode(root);
tree.render();
</script>
</head>
<body>
<div id = "tree"></div>
</body>
</html>
在浏览器中查看,出现错误:
错误: 'dom' 为空或不是对象
求帮助解决!
------解决方案--------------------
把你的代码放到Ext.onReady函数里就行了,先把官网的例子用键盘做一遍。