为什么总是出现Ext.xx.xx is not a constructor的问题,是导入的js文件不对?
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'ext1.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<link rel="stylesheet" type="text/css" href="css/ext-all.css">
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var root = new Ext.tree.TreeNode({
id:"root",
text:"树的根"
});
root.appendChild(new Ext.tree.TreeNode({
id:"c1",
text:"子节点"
}));
var tree = new Ext.tree.TreePanel({
renderTo:"hello",
root:root,
width:100
});
});
</script>
  </head>
  
  <body>
<div id="hello"></div>
  </body>
</html>

解决方案 »

  1.   


    <link rel="stylesheet" type="text/css" href="extjs/ext-4.0.0-gpl/ext-4.0.0/resources/css/ext-all.css" />
    <script type="text/javascript" src="extjs/ext-4.0.0-gpl/ext-4.0.0/bootstrap.js"></script>
    <script type="text/javascript">
     Ext.onReady(function() {
     var store = Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true, 
            text:"",
            user:"",
            status:"", 
            children: [
                { text:"detention", leaf: true },
                { text:"homework", expanded: true, 
                    children: [
                        { text:"aaa"},
                        { text:"bbb"}
                    ]
                },
                { text: "buy lottery tickets", leaf:true }
            ]
        }
    });    var tree=Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
    store: store,
        height: '100%',
        
        rootVisible: false,
    listeners : {  
            'itemclick' : function(view,re){  
       alert(re.data.id);
     
            }  
        }  
    });
      

  2.   

    直接给JSON就好了别NEW来NEW去的
      

  3.   

    原来还没结的!我的问题是项目中没有把ext所需要的js导进去,后面我把下载的ext文件全导进去,ok了!