我看到下面的一段TypeScript,“this”用作函数的参数。什么意思?为什么像这样使用它? ----“brushended(this:SVGGElement){”。在作为函数参数使用的Typescript中,“this”的含义
function brushended(this: SVGGElement) {
let e = <D3BrushEvent<any>>d3.event;
let s: BrushSelection = e.selection;
if (!s) {
if (!idleTimeout) {
self.ngZone.runOutsideAngular(() => {
idleTimeout = window.setTimeout(idled, idleDelay);
});
return idleTimeout;
}
x.domain(x0);
y.domain(y0);
} else {
x.domain([s[0][0], s[1][0]].map(x.invert, x));
y.domain([s[1][1], s[0][1]].map(y.invert, y));
d3Svg.select<SVGGElement>('.brush').call(brush.move, null);
}
zoom();
}
这意味着[文件说,它确实]什么(https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters)。 – 2017-08-16 05:02:52