Uncaught TypeError: Cannot read property 'createChild' of undefined

The error is: Uncaught TypeError: Cannot read property 'createChild' of undefined
1. Reason analysis:
   The js code is not placed in the Ext.onReady function, and the deep-seated reason has not been understood. . .

2. Error code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gbk">
	<title>Forms and Input Controls</title>
	<link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css" />
    <script type="text/javascript" src="../ext-all.js"></script>
    <script type="text/javascript" src="Chinese.js"></script>
    <script type="text/javascript">
    	var form = new Ext.form.FormPanel({
			title : 'form',
			defaultType : 'textfield',
			buttonAlign : 'center',
			frame : true,
			width : 220,
			fieldDefaults : {
				labelAlign : 'right',
				labelWidth : 70
			},
			items : [{
				fieldLabel : 'text box'
			}],
			buttons : [{
				text : 'button'
			}]
		});

	form.render("form");
    </script>
	</head>
	<body>
	       <div id="form"></div>
	</body>
</html>


3. Corrected code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gbk">
	<title>Forms and Input Controls</title>
	<link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css" />
    <script type="text/javascript" src="../ext-all.js"></script>
    <script type="text/javascript" src="Chinese.js"></script>
    <script type="text/javascript">
    	Ext.onReady(function() {
			var form = new Ext.form.FormPanel({
				title : 'form',
				defaultType : 'textfield',
				buttonAlign : 'center',
				frame : true,
				width : 220,
				fieldDefaults : {
					labelAlign : 'right',
					labelWidth : 70
				},
				items : [{
					fieldLabel : 'text box'
				}],
				buttons : [{
					text : 'button'
				}]
			});

			form.render("form");
		})

	form.render("form");
    </script>
	</head>
	<body>
	       <div id="form"></div>
	</body>
</html>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326834984&siteId=291194637