gpt4 book ai didi

module - aureliajs 条件父布局

转载 作者:行者123 更新时间:2023-12-04 23:36:02 33 4
gpt4 key购买 nike

我正在用 aureliajs 编写我的客户端应用程序。默认情况下,对于这样的路由:

/app/access/management

我的应用程序呈现如下:

rendering schema

例如,假设标题和侧边栏在 app 上呈现。然后是 access 中的普通容器最后是 management 中的主要 html .

现在我有一个 access 的子组件例如名称 list .在这个组件中,我希望在没有任何父容器(没有父 html 标记)的情况下呈现页面。

所以我想我有一些解决方案:
  • 制作list在另一个模块中,例如 /app1/access/list它不会在 app1 和访问上呈现任何额外的 html。
  • app 内设置条件和 access决定绘制页眉和页脚等。
  • 调用 list 中的函数在 parent 中隐藏绘制的布局。

  • 但我找不到最好的方法。例如,一种告诉 parent 不要渲染某些东西的方法。

    最佳实践或模式是什么?

    最佳答案

    Similar to MVC-style master/layout pages, Aurelia allows you to use a "layout" view like an MVC "master template" for a set of views.

    The set of views subject to being part of a layout is defined in Aurelia as a set of views referenced by one or more routes in a router configuration. There are two ways to associate a layout with routes. The first is via HTML, the second is via view model code. ...





    ... To specify a layout on the router-view custom element, we use the following attributes:

    • layout-view - specifies the file name (with path) of the layout view to use.
    • layout-view-model - specifies the moduleId of the view model to use with the layout view.
    • layout-model - specifies the model parameter to pass to the layout view model's activate function. ...


    然后通过路由配置:

    ... We can also associate layouts with route configurations using code in our view model. Suppose we like what we've done above, but we have a couple views that we would like to associate with a different layout and would thus like to partially override the configuration given in the HTML. The following code is an example of how we can do that: ...



    建议你仔细阅读这篇文章: aurelia router configuration --> Layouts

    关于module - aureliajs 条件父布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55556846/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com