Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将函数应用于多个对象_Javascript - Fatal编程技术网

Javascript 将函数应用于多个对象

Javascript 将函数应用于多个对象,javascript,Javascript,我有以下代码: this.resize2.intrface.transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}", this.resize2.intrface.ox, this.resize2.intrface.oy,

我有以下代码:

this.resize2.intrface.transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                                    this.resize2.intrface.ox,
                                    this.resize2.intrface.oy,                                                
                                    xmove,    
                                    ymove,
                                    this.resize2.bbx,
                                    this.resize2.bby,
                                    this.resize2.intrface.scale));
this.resize2.core.transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                                    this.resize2.intrface.ox,
                                    this.resize2.intrface.oy,                                                
                                    xmove,    
                                    ymove,
                                    this.resize2.bbx,
                                    this.resize2.bby,
                                    this.resize2.intrface.scale));
我想将变换函数应用于一行中的两个对象。这可能吗?要了解我打算做什么,请参见以下(不起作用)示例:

$(this.resize2.intrface, this.resize2.core).transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                                    this.resize2.intrface.ox,
                                    this.resize2.intrface.oy,                                                
                                    xmove,    
                                    ymove,
                                    this.resize2.bbx,
                                    this.resize2.bby,
                                    this.resize2.intrface.scale));

谢谢

这是关于一些重复的代码重构

function transform(factoryMethod) {
    factoryMethod(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                    this.resize2.intrface.ox,
                    this.resize2.intrface.oy,
                    xmove,    
                    ymove,
                    this.resize2.bbx,
                    this.resize2.bby,
                    this.resize2.intrface.scale));
}
使用此命令调用:

transform.apply(this, [this.resize2.intrface.transform]);
transform.apply(this, [this.resize2.core.transform]);

应该是
$(this.resize2.intrface,this.resize2.core)
?这是正确的。我已经编辑了代码。(顺便说一句,这不是它不起作用的原因)这会产生以下错误:未捕获类型错误:无法读取未定义raphael-min.js:8 a.的属性“transform”。_extractTransformRaphael-min.js:8 a.transform raphael-min.js:8转换索引:224 mover2索引:233 k raphael-min.js:8 bYraphael-min.js:8楼