【问题标题】:How to navigate to another component in Nativescript?如何导航到 Nativescript 中的另一个组件?
【发布时间】:2020-01-31 22:02:36
【问题描述】:

我有一个上传图片的函数,我想在结束这个函数后导航到下一个组件。在 app-routing.module.ts 我做了必要的配置,但我不知道如何做 navigation 。

【问题讨论】:

    标签: nativescript


    【解决方案1】:

    听起来你正在使用角度。

    import { RouterExtensions } from 'nativescript-angular/router';
    
    // ...
    
      constructor(private routerEx: RouterExtensions) {
      }
    
      yourFunction(): void {
        // do your stuff
    
        this.routerEx.navigate(['your route']);
      }
    

    【讨论】:

    • 即使我从模态对话框中执行此操作?
    • 你会在你的模态回调中调用这个函数。如果没有任何工作来源,很难更具体地回答。你能提供一个playground吗?
    • 当您处理模态响应 (if (response == ...) 时,请执行我在上面的回答中提供的 this.routerEx.navigate
    • 好的,它工作,我添加onClose(status:string){ this.params.closeCallback(status); } 和函数uploadPhoto this.onClose('success')
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-03
    • 2019-08-20
    • 2018-05-31
    • 2018-05-31
    • 1970-01-01
    相关资源
    最近更新 更多