1

我在 Angular 9 中有一个问题(在 Angular 7 中,我没有这个问题)。在我的测试中,我有这个:

const spyWindoScroll = spyOn(window, 'scroll');

...

期望(spyWindoScroll).toHaveBeenCalledWith({ 行为:'smooth',左:0,顶部:-50 });

但是当我启动 ng 测试时,我有这个错误:

错误 TS2554:预期 2 个参数,但得到 1 个。

我不明白,因为 window.scroll 对方法滚动有两个定义

interface Window extends ...
...
scroll(options?: ScrollToOptions): void;
scroll(x: number, y: number): void;

...

任何想法来解决这个问题?

谢谢

4

0 回答 0