【问题标题】:What is the best way to create a multipage form in NativeScript Angular在 NativeScript Angular 中创建多页表单的最佳方法是什么
【发布时间】:2016-10-05 21:15:56
【问题描述】:

我正在创建我的第一个 NativeScript Angular 应用程序,它由一个需要跨越多个屏幕的表单组成。 我尝试有创意并使用TheOriginalJosh/nativescript-slides 将表单页面添加到幻灯片中。这实际上效果很好,因为我能够顺利滑动到每个表单页面。

但是当最初导航到表单组件时开始出现问题,因为它开始需要几秒钟才能加载。我假设这是因为表单跨越 10 页,每张幻灯片中有多个 GridLayouts。我考虑过使用 TabView,但我不需要它的菜单部分,我担心它会导致加载速度出现同样的问题。

那么实现这一点的最佳方法是什么? 我应该只创建 10 多个表单组件,使用通用服务并将每个表单部分路由到另一个表单部分,还是有更好的方法将其“封装”到一个组件中而不会造成任何性能损失?

我还在 NativeScript 文档中看到了关于此的内容..

可以将<router-outlet> 组件嵌套在<page-router-outlet> 或其他内部 <router-outlet>

但是没有任何关于如何实现这一点的文档。

【问题讨论】:

    标签: nativescript angular2-nativescript


    【解决方案1】:

    ns中嵌套router-outlet的使用方式有很多种,在一个非常大的项目中,最好使用共享模块架构,这样可以将一个模块嵌套在另一个模块中,这样视图也可以嵌套。

    这是我使用共享模块架构嵌套的 nativescript 示例:

    配置文件中的

    嵌套在 app.component 中。

    在父视图中: https://github.com/Arthurisme/auth0-iosmorphic/blob/master/Mobile/Nativescript-for-Spring-Auth0/app/app.component.ts

    在子视图中: https://github.com/Arthurisme/auth0-iosmorphic/blob/master/Mobile/Nativescript-for-Spring-Auth0/app/profile/profile.component.html

    【讨论】:

    • 感谢您的回复。我认为在有人提出更好的选择之前,嵌套路由会工作得最好,但我似乎无法让它工作.. 嵌套路由时出现错误。 { path: "form", component: FormComponent, children: [ { path:"outcome", component: OutcomeComponent, outlet: "addhand"}, { path: "endon", component: EndonComponent, outlet: "addhand"} ] } 这给了我一个错误......在承诺中错误:无法匹配任何路线:'form'
    • 没关系。我让它工作了。我不得不删除 outlet:"addhand" 并且它有效。在我学会任何其他方式之前,我会继续这样做。再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2017-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多