2017-10-14 15 views
2

の内部コンテンツの追加:は、私はVUEコンポーネントJumbotron.vueを持っVUEコンポーネント

<template lang="html"> 
    <div class="jumbotron" style="border-radius:0px; color:#fff;"> 
    <div class="container"> 

    </div> 
    </div> 
</template> 

そして、他のページコンポーネントMain.vue:

<template> 
    <div class="root"> 
    <navbar></navbar> 
    <jumbotron> 
     <h1 class="display-4">I want to add here, to the jumbotron's div container some h1 and paragraph</h1> 
     <p class="lead ">Like this paragraph</p> 
    </jumbotron> 
    <words></words> 
    </div> 
</template> 

しかし、私はジャンボトロンにコンテンツを追加カントそれは間違っているからです。 Jumbotron.vueの中に別のコンテンツを1回以上使いたいので、Jumbotron.vueの中にコンテンツ(pとh1)を追加したくない。これは可能ですか?

答えて

2

これはslotsで行われます。あなたが親にjumbotronコンポーネント内に入れ

<template lang="html"> 
    <div class="jumbotron" style="border-radius:0px; color:#fff;"> 
    <div class="container"> 
     <slot></slot>  
    </div> 
    </div> 
</template> 

すべてがスロットにレンダリングされます。

関連する問題