Home Web Front-end JS Tutorial Example of using mixins to implement multiple inheritance in ExtJS4_extjs

Example of using mixins to implement multiple inheritance in ExtJS4_extjs

May 16, 2016 pm 05:10 PM
mixins multiple inheritance

Use mixins to implement multiple inheritance in ExtJS4. The specific example code is as follows:

Copy code The code is as follows:

(function(){
Ext.onReady(function(){
Ext.define('say',{
canSay:function(){
alert("hello");
}
});
Ext.define('eat',{
caneat:function(){
alert("eating");
}
});
Ext.define("user ",{
mixins:{
csay:'say',
ceat:'eat'
}
});
var ss = Ext.create("user", {});
ss.caneat();
ss.canSay();
});
})();

One thing to note is mixins The difference from extend is that extend can only implement single inheritance because the parameter followed by extend can only be a string of type String, and files cannot be separated by commas.

Multiple classes can be loaded in mixins to achieve the effect of multiple inheritance.
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of C++ friend functions: What is the role of friend functions in multiple inheritance? Detailed explanation of C++ friend functions: What is the role of friend functions in multiple inheritance? Apr 29, 2024 pm 06:39 PM

Friend functions allow non-member functions to access private members and play a role in multiple inheritance, allowing derived class functions to access private members of the base class.

The purpose of interfaces in Java and the classification of application scenarios The purpose of interfaces in Java and the classification of application scenarios Jan 03, 2024 pm 04:29 PM

Classification and usage scenarios of interfaces in Java 1. Classification of interfaces In Java, an interface is a standardized definition that is used to define the methods that a class should implement. Interfaces can be divided into the following types: Regular interface: Regular interface is the most common type of interface, which defines the methods that a class should implement. For example: publicinterfaceShape{doublecalculateArea();//Method to calculate area doubleca

How to implement multiple inheritance in python How to implement multiple inheritance in python Dec 11, 2023 pm 02:04 PM

In Python, multiple inheritance can be implemented by defining a class with multiple parent classes separated by commas. Detailed introduction: When a class inherits multiple parent classes, it will inherit the properties and methods of all parent classes. This means that subclasses can access and use properties and methods defined in the parent class.

Methods to implement multiple inheritance in Java and analysis of its applicable scenarios Methods to implement multiple inheritance in Java and analysis of its applicable scenarios Jan 30, 2024 am 08:29 AM

Analysis of Java multiple inheritance implementation methods and application scenarios Summary: Java is an object-oriented programming language that supports single inheritance of classes. However, sometimes we need a class to inherit properties and methods from multiple classes. This article will introduce how to implement multiple inheritance in Java and its application scenarios, and give specific code examples. Concepts, Advantages and Disadvantages of Multiple Inheritance Multiple inheritance means that a class can inherit properties and methods from multiple classes. The advantage is that it can improve code reusability and flexibility, allowing developers to more easily combine the functions of multiple classes

What is the impact of C++ function overloading in multiple inheritance? What is the impact of C++ function overloading in multiple inheritance? Apr 26, 2024 pm 02:06 PM

In multiple inheritance, function overloading in the derived class results in hiding or overriding the base class function, depending on whether the signatures are the same. The diamond inheritance structure can lead to ambiguity because the derived class does not know which base class function to call. Ambiguities can be resolved using explicit scope resolvers, type conversions, or virtual inheritance.

Using ThinkPHP6 to implement multiple inheritance Using ThinkPHP6 to implement multiple inheritance Jun 20, 2023 am 10:46 AM

ThinkPHP is an open source framework based on the PHP language and is widely used in the development of web applications. In the development of web applications, we often encounter the need to implement multiple inheritance. This article will introduce how to use the ThinkPHP6 framework to implement multiple inheritance. What is multiple inheritance? In object-oriented programming, inheritance is a very important concept. Inheritance means that a class inherits the properties and methods of another class and can be modified or extended on this basis. In inheritance, a subclass can only inherit from one parent class.

How to use mixins to share component properties and methods in Vue How to use mixins to share component properties and methods in Vue Jun 11, 2023 pm 03:02 PM

Vue is a popular JavaScript framework that allows developers to build high-performance, responsive web applications. In Vue, component properties and methods can be shared using Mixins. Mixins allow developers to reuse and maintain component code, improving code reusability and maintainability. In this article, we will learn how to share component properties and methods in Vue using Mixins. 1. What is MixinsMixins is a way to implement code re-implementation in Vue.

How to use multiple inheritance in Python to solve complex code reuse problems How to use multiple inheritance in Python to solve complex code reuse problems Oct 18, 2023 am 09:31 AM

How to use multiple inheritance in Python to solve complex code reuse problems Introduction: Code reusability is a very important factor when writing complex code. Multiple inheritance in Python is a powerful tool that allows a class to inherit properties and methods from multiple parent classes. In this article, we will introduce how to use multiple inheritance in Python to solve the problem of code reuse, and illustrate the use of multiple inheritance through specific code examples. 1. What is multiple inheritance? Multiple inheritance means that a class can inherit properties from multiple parent classes

See all articles