*빨간 부분 코드 먼저 봐주세요
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<app-header></app-header>
<app-content></app-content>
<app-footer></app-footer>
</div>
<div id="app2">
<app-header></app-header>
<app-footer></app-footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
//전역 컴포넌트
Vue.component('app-header', {
template:'<h1>Header</h1>'
});
Vue.component('app-content',{
template:' <div>content</div>'
});
new Vue({
el: '#app',
components: {
//지역 컴포넌트 등록 방식
//'컴포넌트 이름': 컴포넌트 내용,
'app-footer':{
template:'<footer>footer</footer>'
}
}
});
new Vue({
el:'#app2',
components:{
'app-footer':{
template:'<footer>footer</footer>'
}
}
})
*새로운 new Vue app2를 만들었으나, 개발자도구에서 새로운 root가생성되지 않아 질문드립니다. (아래사진참조)
</script>
</body>
</html>