Home  >  Article  >  WeChat Applet  >  ES6 new features development WeChat applet (3)

ES6 new features development WeChat applet (3)

迷茫
迷茫Original
2017-03-25 17:26:301699browse

Class(Class)

Class is one of the most important features introduced in ES6. Before Class, we could only simulate classes through the prototype chain.

Class Definition (class definition)

ES6 new features development WeChat applet (3)

##The above defines a Shape class, it has an attribute name and a method move(), as well as a constructor.

Call the Shape class

ES6 new features development WeChat applet (3)

Class Inheritance(Class Inheritance)

Inherit a class through the keyword extends, and refer to the parent class through the super keyword.

ES6 new features development WeChat applet (3)

##Call the Rectangle and Circle classes

ES6 new features development WeChat applet (3)

Getter/Setter


You can use the get and set keywords inside Class to set a certain The attribute sets the value storage function and the value function to intercept the access behavior of the attribute.

ES6 new features development WeChat applet (3)
##Static Members

Class equivalent Based on the prototype of the instance, all methods defined in the class will be inherited by the instance. If the static keyword is added before a method, it means that the method will not be inherited by the instance, but will be called directly through the class. This is called a "static method".

ES6 new features development WeChat applet (3)
Static properties refer to the properties of the Class itself, i.e. Class.propname, rather than defined in the instance Properties on the object (this)

ES6 new features development WeChat applet (3)

The above is the detailed content of ES6 new features development WeChat applet (3). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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