在没有装饰器之前不方便。
可以用Reflect.apply。
cls = function f() { ?let obj = {}; ?obj.show = function(a, b) { ???console.log(a + b); ?} ?return obj;}function trans(a, b) { ?let o = cls(); ?Reflect.apply(o.show, o, [a, b]); // 关键是这里,apply函数会自动解开数组!}trans(1, 4);
JS参数转发
原文地址:https://www.cnblogs.com/willaty/p/9399035.html