In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about the use of Ext.define in Ext.js4.2.1. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
One: description
Define (String className, Object data, Function createdFn): Ext.Base
The define method accepts up to three parameters, className (class name), data (Object object), and createdFn (callback function).
Often used to define a class, override a class, or extend the properties or methods of a class.
Two: method explanation
Ext.define ("Person", {
Config: {
Name:''
Age: 0
}
Say: function (msg) {
Ext.Msg.alert (this.Name + "Says:", msg)
}
Constructor: function (config) {
This.initConfig (config)
}
});
Ext.define ("Animal", {
Sing: function () {
Ext.Msg.alert ("Sing", "lalalalalallalalal")
}
});
Ext.define ("MyApp.Developer", {
Extend: 'Person'
Mixins: {
CanSing: 'Animal'
}
Alias: 'Developer'
Requires: []
Config: {}
Coding: function (code) {
Ext.Msg.alert (this.Name + "coding", code)
}
Statics: {
Test: function (msg) {
Return "Test" + msg
}
}
});
Var Alex = Ext.create ("Developer", {
Name: "Alex"
Age: 26
});
Alex.setAge (33)
Alert (Alex.getAge ())
Alert (MyApp.Developer.test ('any Wayside'))
Alex.Sing ()
Alex.Coding ("int iTunes 1;")
1.config
Configuration item. This.initConfig (config) is called to initialize the configuration item. Four functions are automatically generated for each configuration item: get,set,reset,apply
2.extend
Used for inheritance of classes
3.mixins
Class, similar to Ext.override. But it will not overwrite the original functions like override.
4.alias
Alias of the class
5.requires
ExtJS4's requires is a new mechanism, which mainly implements asynchronous loading mechanism. In this way, the corresponding js file will not be loaded without clicking the corresponding button or option, 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 that the file is looking for, and then uses Ext.require to load when the corresponding js file is needed.
6.statics
You can define static methods in a class
Three: other
1.Ext.apply (object,config, [defaults]): Object
The method contains three parameters, the first parameter is the target object to be copied, the second parameter is the copied source object, and the third parameter is optional, indicating that a default value is provided to the target object. It can be simply understood as copying the third parameter (if any) and the attributes in the second parameter to the first parameter object.
2.Ext.applyIf (object,config): Object
The function is the same as apply, except that properties that exist in both the target object and the source object are not copied
Thank you for reading! This is the end of this article on "what is the use of Ext.define in Ext.js4.2.1?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.