0
を実装し、これは私がやったことです:角度2 - 私は私自身のUrlSerializerクラスを実装しようとしているUrlSerializer
c:/xampp/htdocs/proj/src/app/custom-url-serializer.ts (11,12): 'super' can only be referenced in a derived class.
c:/xampp/htdocs/proj/src/app/custom-url-serializer.ts (16,12): 'super' can only be referenced in a derived class.
:
import { UrlSerializer,UrlTree } from '@angular/router';
export class CustomUrlSerializer implements UrlSerializer {
parse(url: string): UrlTree {
// Change plus signs to encoded spaces
url.replace("%20", '-');
// Use the default serializer that you can import to just do the
// default parsing now that you have fixed the url.
return super.parse(url)
}
serialize(tree: UrlTree): string {
// Use the default serializer to create a url and replace any spaces with + signs
return super.serialize(tree).replace("%20", '-');
}
}
私がコンパイルしようとしているとき、私は、次のerrosを取得
どういうところが間違っていますか?
UrlSerializerは抽象メソッドですが、今はsuperを使用できないというエラーが発生します。どうすればデフォルトのURLシリアライザにアクセスできますか? – TheUnreal
ああ、はい、それは本当です。 DefaultUrlSerializerを使用することができますhttps://angular.io/docs/ts/latest/api/router/index/DefaultUrlSerializer-class.html –
ありがとう!しかし、それを私のカスタムクラスにどのようにインポートできますか?抽象のコンストラクタはありません – TheUnreal