稍微书上代码不适合。
var btns = Ext.select('input');
需要更改为:
var btns = Ext.select('input', true);
不然报错:
[E] Ext.dom.Fly.addListener(): Cannot use addListener() on Ext.dom.Flyinstances. Please use Ext.get() to retrieve an Ext.dom.Element inst..。。。
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="ExtJs/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css"> <script type="text/javascript" src="ExtJs/ext-all.js"></script> <script type="text/javascript" src="ExtJs/bootstrap.js"></script> <script type="text/javascript" src="ExtJs/packages/ext-theme-crisp/build/ext-theme-crisp.js"></script> <script type="text/javascript"> Ext.onReady(function(){ var loader = Ext.get('content-div').getLoader(); var btns = Ext.select('input', true); btns.addListener('click', function(e, btn){ var contentUrl = '9-5-' + btn.value + '.html'; load(contentUrl); }); function load(contentUrl){ loader.load({ url: contentUrl }); } }); </script> </head> <body> <div id="content-div" style="width:200px solid #ccc"></div> <input type=button value='page1'> <input type=button value='page2'> </body> </html>