[Vuejs]-How to nest components in cdn setup vue.js project

0๐Ÿ‘

โœ…

Do not call your components A or B. Your components should be composed : https://v2.vuejs.org/v2/guide/components-registration.html

Then just reuse a component inside the template of the other :

Vue.component('component-a',{template: '<p>Hello I am A</p>'})
Vue.component('component-b',{template: '<div><p>Hello I am B</p><component-a></component-a></div>'})

Then display your components :

<div id="app">
    <component-a></component-a>
    <component-b></component-b>
</div>

and

new Vue({
  el: "#app",
})

Leave a comment