我想创建一个UrlTree (角v14)的实例:
const anUrlTree = new UrlTree(root, someParams, aFragment);
但是,从UrlTree
导入的'@angular/router';
类没有构造函数,这意味着签名没有参数。
export declare class UrlTree {
/** The root segment group of the URL tree */
root: UrlSegmentGroup;
/** The query params of the URL */
queryParams: Params;
/** The fragment of the URL */
fragment: string | null;
get queryParamMap(): ParamMap;
/** @docsNotRequired */
toString(): string;
}
因此,我不得不使用以下解决办法:
const nextTree = new UrlTree();
urlTree.root = root;
urlTree.queryParams = someParams;
urlTree.fragment = aFragment;
否则,将参数传递给构造函数将引发错误。
TS2554:期望0参数,但得到3
所以我的问题是:带参数的构造函数在哪里?
发布于 2022-08-30 09:40:21
好的,明白了,…构造函数的论点只是增加了 (12天前写了这个问题)
https://stackoverflow.com/questions/73540206
复制相似问题