一般我们在网页中中引用html或jsp文件,都是在页面文件中通过一下方式静态的引用
<script type="text/javascript" src="./js/PlanApply/monthrepairinfo.js"></script>
要使用动态加载,首先要设置Ext.Loader的enabled配置项为true,在Ext的API文档中,原文如下
enabled : Boolean Whether or not to enable the dynamic dependency loading feature. Defaults to: false Available since: 4.0.0
test.js
/** * 定义一个方法,用来显示Form */ function displayForm() { var win=Ext.create("js.test",{ title:'动态加载js测试页面', height:300, width:300 }); win.show(); } /** * 定义一个类 */ Ext.define('js.test',{ extend:'Ext.window.Window' }) ; Ext.onReady
require成功后有一个回调函数,在这里我们调用test.js中的displayForm方法显示界面
function btnClick(optype){ Ext.require('js.test',function(){ displayForm(); }) }