2017-08-22 5 views
1

Aureliaにコンポーネントをカプセル化せずにカスタム要素を表示させることはできますか?または、カスタムエレメントノードをそのコンテンツで置き換えますか?外部ノードを持たない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> 

結果

この例に基づいて

enter image description here

:それは何のcustom-component -nodeが生じないようにアウレリアで、<body>の直接の子としてコンポーネントから<p>要素をレンダリングすることは可能ですか?

答えて

2

コンポーネントにcontainerless属性を使用します。

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

あなたもcontainerless()デコレータを使用してカスタムコンポーネントを飾ることができます。 参照:http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/cheat-sheet/9

+0

ありがとうございます!できます。 –

+3

'containerless'属性/デコレータは、絶対に必要なときにのみ使用してください。いくつかのカスタム要素の機能を制限します。 –

関連する問題