中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何实现一个NavPathStack的派生类?
微信扫码分享
class MyNavPathStack extends NavPathStack { // usr defined property 'id' id: string = "__default__" // new function in derived class setId(id: string) { this.id = id; } getInfo(): string { return "this page used Derived NavPathStack, id: " + this.id } //重写NavPathStack的方法 pushPath(info: NavPathInfo, animated?: boolean): void pushPath(info: NavPathInfo, options?: NavigationOptions): void pushPath(info: NavPathInfo, secArg?: boolean | NavigationOptions): void { console.log('[derive-test] reached DerivedNavPathStack\'s pushPath'); if (typeof secArg === 'boolean') { super.pushPath(info, secArg); } else { super.pushPath(info, secArg); } } pop(animated?: boolean | undefined): NavPathInfo | undefined pop(result: Object, animated?: boolean | undefined): NavPathInfo | undefined pop(result?: Object, animated?: boolean | undefined): NavPathInfo | undefined { console.log('[derive-test] reached DerivedNavPathStack\'s pop'); return super.pop(result, animated); } }