亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Can class attributes and methods be separated into files in ES6?
僅有的幸福
僅有的幸福 2017-06-28 09:28:59
0
1
953

To define class in es6, you can do this

class A {
    x = 1;
    y = 2;
    z = 3;
    mx () { // ... }
    my () { // ... }
    mz () { // ... }
}

When there are more and more A class attribute methods, it is found that the entire file has a large amount of code. Can some properties and methods be divided into a single file (for example, x and mx are divided into one x.js file, y and my are divided into one y.js file...)

If you use extends, you will find a problem. Properties cannot be shared, and neither can methods.

Can we combine (x.js / y.js / ...) into A when defining class A?

僅有的幸福
僅有的幸福

reply all(1)
阿神

MixinMode

In short, it is to merge the prototype attributes of several classes, and the last big class can inherit this merged class.

Ruan Yifeng’s ES6 tutorial has a sample program, you can refer to: Mixin-pattern implementation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template