嵌套的Aurelia应用程序 [英] Nested Aurelia applications

查看:66
本文介绍了嵌套的Aurelia应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Aurelia的创建者Rob Eisenberg,应该有可能彼此嵌套的aurelia应用程序.

According to Rob Eisenberg, the creator of Aurelia, it should be possible to have nested aurelia applications inside each other.

由于他在上面的链接中提到的示例不再公开,因此如果这里的任何人可以进一步阐述,甚至链接或编写有关如何实现这种嵌套的小示例.

Since the example he mentions in the above link is not public anymore, it'd be very helpful if anyone here could elaborate further, or even link or write a small example of how this sort of nesting would be implemented.

我希望使用Aurelia创建的主要应用程序和界面将包含一个Windows XP Desktop样式的外壳,其中可以从开始菜单打开嵌套的Aurelia应用程序,并在其中的嵌入式窗口中打开主要应用程序"Windows桌面区域"(例如Windows或文件资源管理器)将在常规Windows XP OS中但在SPA中打开.

The main application and interface I'm hoping to create with Aurelia would consist of a Windows XP Desktop style-ish shell, in which one would be able to open nested Aurelia applications from the start menu, opening in an embedded window inside the main applications "windows desktop area" - like a windows or file explorer would open in a normal Windows XP OS, but inside the SPA.

要使其真正可扩展,我宁愿保留将嵌套的aurelia应用程序放置在主应用程序根文件夹之外的文件夹中的可能性,而不是使用磁盘上的文件/文件夹路径从主应用程序链接到它们.

To make this truly extendable I would prefer keeping the possibility of placing the nested aurelia applications in folders outside the main applications root folder, and instead linking to them from the main application using a file/folder path on the disk.

因此,为了使其简单",请想象成为主要应用程序(Windows外壳)-单击该按钮可打开一个窗口,该窗口可以最小化,调整大小或移动.在该窗口中,将打开另一个aurelia应用程序.最后,您希望能够将某些状态从主应用程序转移到嵌套应用程序,例如.语言或数据库.

So to keep it "simple", imagine this would be the main application (the windows shell) - clicking the button opens a window, which can be minimized, resized or moved around. In that window another aurelia application would open. And in the end you would hopefully be able to transfer certain state from the main application to the nested apps, like eg. the language or database.

如果可能的话,最好是可以从主应用程序根文件夹外部找到并引用嵌套的应用程序.

And if possible it would be optimal if the nested application could be located and referenced from outside the main applications root folder.

推荐答案

以下是示例: https://gist.run?id=7cda93aa0a225805ddf6

Here's an example: https://gist.run?id=7cda93aa0a225805ddf6

app.html

<template>
  <require from="./child-app"></require>

  <child-app main.bind="main1"></child-app>
  <child-app main.bind="main2"></child-app>
</template>

app.js

export class App {
  main1 = './one/app';
  main2 = './two/app';
}

child-app.js

import {
  Aurelia,
  noView,
  bindable,
  inject,
  Container
} from 'aurelia-framework';
import {Loader} from 'aurelia-loader';

@noView()
@inject(Loader, Element)
export class ChildApp {
  @bindable main;

  constructor(loader, element) {
    this.host = element;
    this.app = new Aurelia(this.loader, new Container());
    this.app.use.standardConfiguration();
  }

  mainChanged() {
    this.app.start().then(a => a.setRoot(this.main, this.host));
  }
}

这篇关于嵌套的Aurelia应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆