Using Ext.define to customize classes

Source: Internet
Author: User

ExtJS allows users to use Ext.define custom classes. This article will show you how to use the Ext.define custom class using an example, and describes how to use the dynamic load (require method) of ExtJS.

JavaScript Custom Classes

In JavaScript, the custom class is this:

//in JavaScript, the custom classvarperson =function(name, age) { This. Name = "";  This. Age = 0;  This. Say =function(msg) {alert ( This. Name + "Says:" +msg); }     This. init =function(name, age) { This. Name =name;  This. Age =Age ; }     This. Init (name, age);}

In this code, we define the person class, which has the name and age two properties, with the Say and init public methods. When a class is created, the initialization of the class is defined by calling the Init method (so the Init method can be thought of as the constructor of the class). Let's take a look at the usage of this class:

var New Person ("Tom", +); Tom.say ("Hello");

Run effect

We've simply introduced how to customize classes in native JavaScript, because this article focuses on the methods of customizing classes in ExtJS, so more about JavaScript custom objects, you can refer to my previous article: "Custom JavaScript Class", Let's go to the bottom of this article and see How to use the Extjs.define method to customize the class.

Custom Classes in ExtJS

In ExtJS, we also define a person class, first look at the specific code:

Using Ext.define to customize classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.