0

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']
      }
    })
1
  • 3
    You're rendering a paragraph tag inside each span. Commented Apr 30, 2018 at 14:23

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.