Enirdas
Enirdas

Reputation: 129

vue.js component template rendering

In the following code I expected everything to be rendered inline, but they are not. Why isn't the component rendered inline when it is a span?

    <div id='app'>
        <span v-for="ville in nomVilles">
           <span>{{ville}}  </span>
        </span>

       <liste-villes :villes ="nomVilles"></liste-villes>  
    </div>



    Vue.component('liste-villes',{
      template: '<span >\
                   <span v-for="ville in villes">\
                      <p>{{ville}} </p>\
                   </span>\
               </span>  ',
      props: ['villes']
    });

    var vm = new Vue ({
      el:'#app',
      data: {
        nomVilles:['Vancouver','Montreal']
      }
    })

Upvotes: 0

Views: 143

Answers (1)

Sammi
Sammi

Reputation: 286

The span element is an inline element, while the p tag is a block element.

You are trying to render a paragraph element inside a span tag, so it still takes up the entire block level, forcing the next span to not be inline.

Upvotes: 2

Related Questions