没有外部节点的 Aurelia 自定义元素

Aurelia custom element without outer node

是否可以让Aurelia在没有封装组件节点的情况下渲染自定义元素?或者用它的内容替换自定义元素节点?

示例:

app.html

<template>
  <require from = "./components/custom-component.html"></require>
     <custom-component></custom-component>
</template>

app.ts

export class App {
}

自定义-component.html

<template>
    <p>This is some text from dynamic component...</p>
</template>

结果

基于此示例:aurelia 是否可以将组件中的 <p> 元素渲染为 <body> 的直接子元素,这样就不会有 custom-component-节点?

在您的组件上使用 containerless 属性。

示例:https://gist.run/?id=8e57000c7b8423dc0246a7006d90ba79

您还可以使用 containerless() 装饰器装饰您的自定义组件。 参见:http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/cheat-sheet/9