@b(‘argarg’) 相当于 A = b(‘argarg’)(A)
装饰器在作用在类上的时候便已经执行完 最开始的函数,装饰器隐形的将 被装饰者作为最后一个参数传入进 装饰函数并执行1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22const b = (arg) => Comp => {
return class C {
constructor() {
console.log('ccccccc')
}
say() {
console.log(`i am ${arg}`)
}
}
}
@b('argarg')
class A {
constructor() {
console.log('aaa')
}
}
// let oth = b('feafea')(A)
let aha = new A()
aha.say()
1 | let func1 = (arg1) => (arg2) => { |