Example introduction to using requires in ExtJS4_extjs
WBOY
Release: 2016-05-16 17:10:55
Original
1494 people have browsed it
ExtJS4's requires is a new mechanism, mainly to implement asynchronous loading mechanism. In this way, the corresponding js file will not be loaded unless the corresponding button or option is clicked, which improves the loading speed and user waiting time.
The implementation of the requires mechanism uses an Ext.Loader.setConfig function to set the mapping directory for file search, and then use Ext.require to load the corresponding js file when it is needed. The storage structure of
files is as follows:
The ux folder is in the same directory as lesson2.htm and lesson22.js, and the MyWin.js used is stored in ux in the folder.
In this code piece, MyWin.js in the ux directory is not loaded. file, then when the page is loaded, the MyWin.js file will not be loaded at the same time, but will only be loaded when needed. The need here is achieved by clicking the button.
The content of the lesson22.js file is as follows:
ux directory The contents of the MyWin.js file under .define('ux.MyWin',{ extend:'Ext.window.Window',
title:'sign up', width:400, height:300 } ); Note: The file name MyWin and the function name here must be the same. I tested it, and if they are different, it will not be displayed.
At the beginning, I used the method of writing in the second lecture of the ExtJS4 teaching video on uspcat, but the result I wanted could not appear. It may be a version problem or my own problem. By With this modification, you can use the requires method. This is a note for anyone who has the same confusion.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn